Skip to content

Commit 12b889e

Browse files
committed
ecc_get_set_by_name
1 parent aca515c commit 12b889e

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/pk/ecc/ecc_get_set.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
10+
#include "tomcrypt.h"
11+
12+
#ifdef LTC_MECC
13+
14+
int ecc_get_set_by_name(const char* name, const ltc_ecc_set_type** dp)
15+
{
16+
int i;
17+
18+
LTC_ARGCHK(dp != NULL);
19+
LTC_ARGCHK(name != NULL);
20+
21+
*dp = NULL;
22+
23+
for (i = 0; ltc_ecc_sets[i].size != 0 && ltc_ecc_sets[i].name != NULL; i++) {
24+
if (XSTRCMP(ltc_ecc_sets[i].name, name) == 0) break;
25+
}
26+
27+
if (ltc_ecc_sets[i].size == 0 || ltc_ecc_sets[i].name == NULL) {
28+
/* not found */
29+
return CRYPT_INVALID_ARG;
30+
}
31+
32+
*dp = &ltc_ecc_sets[i];
33+
return CRYPT_OK;
34+
}
35+
36+
#endif
37+
38+
/* ref: $Format:%D$ */
39+
/* git commit: $Format:%H$ */
40+
/* commit time: $Format:%ai$ */

0 commit comments

Comments
 (0)