Skip to content

Commit 362275e

Browse files
committed
add ecc_get_oid_str
1 parent e9edb5d commit 362275e

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/headers/tomcrypt_pk.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ int ecc_set_dp(const ltc_ecc_curve *cu, ecc_key *key);
345345
int ecc_generate_key(prng_state *prng, int wprng, ecc_key *key);
346346
int ecc_set_key(const unsigned char *in, unsigned long inlen, int type, ecc_key *key);
347347
int ecc_get_key(unsigned char *out, unsigned long *outlen, int type, const ecc_key *key);
348+
int ecc_get_oid_str(char *out, unsigned long *outlen, const ecc_key *key);
348349

349350
int ecc_make_key(prng_state *prng, int wprng, int keysize, ecc_key *key);
350351
int ecc_make_key_ex(prng_state *prng, int wprng, ecc_key *key, const ltc_ecc_curve *cu);

src/pk/ecc/ecc_get_oid_str.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
/** Extract OID as a string from ECC key
15+
@param out [out] destination buffer
16+
@param outlen [in/out] Length of destination buffer and final output size (without terminating NUL byte)
17+
@param key The ECC key
18+
Return CRYPT_OK on success
19+
*/
20+
21+
int ecc_get_oid_str(char *out, unsigned long *outlen, const ecc_key *key)
22+
{
23+
LTC_ARGCHK(key != NULL);
24+
25+
return pk_oid_num_to_str(key->dp.oid, key->dp.oidlen, out, outlen);
26+
}
27+
28+
#endif
29+
30+
/* ref: $Format:%D$ */
31+
/* git commit: $Format:%H$ */
32+
/* commit time: $Format:%ai$ */

0 commit comments

Comments
 (0)