1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3 #include "tomcrypt_private.h"
4 
5 /**
6    @file ecb_start.c
7    ECB implementation, start chain, Tom St Denis
8 */
9 
10 
11 #ifdef LTC_ECB_MODE
12 
13 /**
14    Initialize a ECB context
15    @param cipher      The index of the cipher desired
16    @param key         The secret key
17    @param keylen      The length of the secret key (octets)
18    @param num_rounds  Number of rounds in the cipher desired (0 for default)
19    @param ecb         The ECB state to initialize
20    @return CRYPT_OK if successful
21 */
ecb_start(int cipher,const unsigned char * key,int keylen,int num_rounds,symmetric_ECB * ecb)22 int ecb_start(int cipher, const unsigned char *key, int keylen, int num_rounds, symmetric_ECB *ecb)
23 {
24    int err;
25    LTC_ARGCHK(key != NULL);
26    LTC_ARGCHK(ecb != NULL);
27 
28    if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
29       return err;
30    }
31    ecb->cipher = cipher;
32    ecb->blocklen = cipher_descriptor[cipher]->block_length;
33    return cipher_descriptor[cipher]->setup(key, keylen, num_rounds, &ecb->key);
34 }
35 
36 #endif
37