|
| 1 | +/* LibTomCrypt, modular cryptographic library -- Tom St Denis */ |
| 2 | +/* SPDX-License-Identifier: Unlicense */ |
| 3 | +#include "tomcrypt_private.h" |
| 4 | + |
| 5 | +/** |
| 6 | + @file pem.c |
| 7 | + Const declarations for PEM, Steffen Jaeckel |
| 8 | +*/ |
| 9 | + |
| 10 | +#ifdef LTC_PEM |
| 11 | + |
| 12 | +const struct pem_header_id pem_std_headers[] = { |
| 13 | + { |
| 14 | + /* PKCS#8 encrypted */ |
| 15 | + SET_CSTR(.start, "-----BEGIN ENCRYPTED PRIVATE KEY-----"), |
| 16 | + SET_CSTR(.end, "-----END ENCRYPTED PRIVATE KEY-----"), |
| 17 | + .has_more_headers = no, |
| 18 | + .encrypted = 1, |
| 19 | + .pkcs8 = 1, |
| 20 | + }, |
| 21 | + { |
| 22 | + /* PKCS#8 plain */ |
| 23 | + SET_CSTR(.start, "-----BEGIN PRIVATE KEY-----"), |
| 24 | + SET_CSTR(.end, "-----END PRIVATE KEY-----"), |
| 25 | + .has_more_headers = no, |
| 26 | + .pkcs8 = 1, |
| 27 | + }, |
| 28 | + /* Regular plain or encrypted private keys */ |
| 29 | + { |
| 30 | + SET_CSTR(.start, "-----BEGIN RSA PRIVATE KEY-----"), |
| 31 | + SET_CSTR(.end, "-----END RSA PRIVATE KEY-----"), |
| 32 | + .has_more_headers = maybe, |
| 33 | + .pka = LTC_PKA_RSA, |
| 34 | + }, |
| 35 | + { |
| 36 | + SET_CSTR(.start, "-----BEGIN EC PRIVATE KEY-----"), |
| 37 | + SET_CSTR(.end, "-----END EC PRIVATE KEY-----"), |
| 38 | + .has_more_headers = maybe, |
| 39 | + .pka = LTC_PKA_EC, |
| 40 | + }, |
| 41 | + { |
| 42 | + SET_CSTR(.start, "-----BEGIN DSA PRIVATE KEY-----"), |
| 43 | + SET_CSTR(.end, "-----END DSA PRIVATE KEY-----"), |
| 44 | + .has_more_headers = maybe, |
| 45 | + .pka = LTC_PKA_DSA, |
| 46 | + }, |
| 47 | +}; |
| 48 | +const unsigned long pem_std_headers_num = sizeof(pem_std_headers)/sizeof(pem_std_headers[0]); |
| 49 | + |
| 50 | + |
| 51 | +/* Encrypted PEM files */ |
| 52 | +const struct str pem_proc_type_encrypted = { SET_CSTR(, "Proc-Type: 4,ENCRYPTED") }; |
| 53 | +const struct str pem_dek_info_start = { SET_CSTR(, "DEK-Info: ") }; |
| 54 | +const struct dek_info_from_str pem_dek_infos[] = |
| 55 | + { |
| 56 | + { SET_CSTR(.id, "AES-128-CBC,"), .info.alg = "aes", .info.keylen = 128 / 8, }, |
| 57 | + { SET_CSTR(.id, "AES-192-CBC,"), .info.alg = "aes", .info.keylen = 192 / 8, }, |
| 58 | + { SET_CSTR(.id, "AES-256-CBC,"), .info.alg = "aes", .info.keylen = 256 / 8, }, |
| 59 | + { SET_CSTR(.id, "CAMELLIA-128-CBC,"), .info.alg = "camellia", .info.keylen = 128 / 8, }, |
| 60 | + { SET_CSTR(.id, "CAMELLIA-192-CBC,"), .info.alg = "camellia", .info.keylen = 192 / 8, }, |
| 61 | + { SET_CSTR(.id, "CAMELLIA-256-CBC,"), .info.alg = "camellia", .info.keylen = 256 / 8, }, |
| 62 | + { SET_CSTR(.id, "DES-EDE3-CBC,"), .info.alg = "3des", .info.keylen = 192 / 8, }, |
| 63 | + { SET_CSTR(.id, "DES-CBC,"), .info.alg = "des", .info.keylen = 64 / 8, }, |
| 64 | + }; |
| 65 | +const unsigned long pem_dek_infos_num = sizeof(pem_dek_infos)/sizeof(pem_dek_infos[0]); |
| 66 | + |
| 67 | +#endif /* LTC_PEM */ |
0 commit comments