Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/tomcrypt/src/modes/ecb/ecb_start.c
5972 views
1
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
2
*
3
* LibTomCrypt is a library that provides various cryptographic
4
* algorithms in a highly modular and flexible manner.
5
*
6
* The library is free for all purposes without any express
7
* guarantee it works.
8
*/
9
#include "tomcrypt.h"
10
11
/**
12
@file ecb_start.c
13
ECB implementation, start chain, Tom St Denis
14
*/
15
16
17
#ifdef LTC_ECB_MODE
18
19
/**
20
Initialize a ECB context
21
@param cipher The index of the cipher desired
22
@param key The secret key
23
@param keylen The length of the secret key (octets)
24
@param num_rounds Number of rounds in the cipher desired (0 for default)
25
@param ecb The ECB state to initialize
26
@return CRYPT_OK if successful
27
*/
28
int ecb_start(int cipher, const unsigned char *key, int keylen, int num_rounds, symmetric_ECB *ecb)
29
{
30
int err;
31
LTC_ARGCHK(key != NULL);
32
LTC_ARGCHK(ecb != NULL);
33
34
if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
35
return err;
36
}
37
ecb->cipher = cipher;
38
ecb->blocklen = cipher_descriptor[cipher].block_length;
39
return cipher_descriptor[cipher].setup(key, keylen, num_rounds, &ecb->key);
40
}
41
42
#endif
43
44