1 // SPDX-License-Identifier: BSD-2-Clause
2 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3  *
4  * LibTomCrypt is a library that provides various cryptographic
5  * algorithms in a highly modular and flexible manner.
6  *
7  * The library is free for all purposes without any express
8  * guarantee it works.
9  */
10 #include "tomcrypt_private.h"
11 
12 #ifdef LTC_DER
13 
14 typedef struct {
15    enum ltc_oid_id id;
16    const char* oid;
17 } oid_table_entry;
18 
19 static const oid_table_entry pka_oids[] = {
20                                               { PKA_RSA,       "1.2.840.113549.1.1.1" },
21                                               { PKA_DSA,       "1.2.840.10040.4.1" },
22                                               { PKA_EC,        "1.2.840.10045.2.1" },
23                                               { PKA_EC_PRIMEF, "1.2.840.10045.1.1" },
24                                               { PKA_X25519,    "1.3.101.110" },
25                                               { PKA_ED25519,   "1.3.101.112" },
26 };
27 
28 /*
29    Returns the OID requested.
30    @return CRYPT_OK if valid
31 */
pk_get_oid(enum ltc_oid_id id,const char ** st)32 int pk_get_oid(enum ltc_oid_id id, const char **st)
33 {
34    unsigned int i;
35    LTC_ARGCHK(st != NULL);
36    for (i = 0; i < sizeof(pka_oids)/sizeof(pka_oids[0]); ++i) {
37       if (pka_oids[i].id == id) {
38          *st = pka_oids[i].oid;
39          return CRYPT_OK;
40       }
41    }
42    return CRYPT_INVALID_ARG;
43 }
44 #endif
45 
46 /* ref:         $Format:%D$ */
47 /* git commit:  $Format:%H$ */
48 /* commit time: $Format:%ai$ */
49