Path: blob/master/libs/tomcrypt/src/modes/ecb/ecb_start.c
5972 views
/* LibTomCrypt, modular cryptographic library -- Tom St Denis1*2* LibTomCrypt is a library that provides various cryptographic3* algorithms in a highly modular and flexible manner.4*5* The library is free for all purposes without any express6* guarantee it works.7*/8#include "tomcrypt.h"910/**11@file ecb_start.c12ECB implementation, start chain, Tom St Denis13*/141516#ifdef LTC_ECB_MODE1718/**19Initialize a ECB context20@param cipher The index of the cipher desired21@param key The secret key22@param keylen The length of the secret key (octets)23@param num_rounds Number of rounds in the cipher desired (0 for default)24@param ecb The ECB state to initialize25@return CRYPT_OK if successful26*/27int ecb_start(int cipher, const unsigned char *key, int keylen, int num_rounds, symmetric_ECB *ecb)28{29int err;30LTC_ARGCHK(key != NULL);31LTC_ARGCHK(ecb != NULL);3233if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {34return err;35}36ecb->cipher = cipher;37ecb->blocklen = cipher_descriptor[cipher].block_length;38return cipher_descriptor[cipher].setup(key, keylen, num_rounds, &ecb->key);39}4041#endif424344