1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3 #include "tomcrypt_private.h"
4 
5 #ifdef LTC_DER
6 
7 typedef struct {
8    enum ltc_oid_id id;
9    const char* oid;
10 } oid_table_entry;
11 
12 static const oid_table_entry pka_oids[] = {
13                                               { LTC_OID_RSA,       "1.2.840.113549.1.1.1" },
14                                               { LTC_OID_DSA,       "1.2.840.10040.4.1" },
15                                               { LTC_OID_EC,        "1.2.840.10045.2.1" },
16                                               { LTC_OID_EC_PRIMEF, "1.2.840.10045.1.1" },
17                                               { LTC_OID_X25519,    "1.3.101.110" },
18                                               { LTC_OID_ED25519,   "1.3.101.112" },
19 };
20 
21 /*
22    Returns the OID requested.
23    @return CRYPT_OK if valid
24 */
pk_get_oid(enum ltc_oid_id id,const char ** st)25 int pk_get_oid(enum ltc_oid_id id, const char **st)
26 {
27    unsigned int i;
28    LTC_ARGCHK(st != NULL);
29    for (i = 0; i < sizeof(pka_oids)/sizeof(pka_oids[0]); ++i) {
30       if (pka_oids[i].id == id) {
31          *st = pka_oids[i].oid;
32          return CRYPT_OK;
33       }
34    }
35    return CRYPT_INVALID_ARG;
36 }
37 #endif
38