1 /** 2 * Copyright Notice: 3 * Copyright 2021-2022 DMTF. All rights reserved. 4 * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md 5 **/ 6 7 /** @file 8 * Defines base cryptographic library APIs. 9 * The Base Cryptographic Library provides implementations of basic cryptography 10 * primitives (hash Serials, HMAC, AES, RSA, Diffie-Hellman, Elliptic Curve, etc) for security 11 * functionality enabling. 12 **/ 13 14 #ifndef CRYPTLIB_H 15 #define CRYPTLIB_H 16 17 #include "internal/libspdm_lib_config.h" 18 19 #define LIBSPDM_CRYPTO_NID_NULL 0x0000 20 21 /* Hash */ 22 #define LIBSPDM_CRYPTO_NID_SHA256 0x0001 23 #define LIBSPDM_CRYPTO_NID_SHA384 0x0002 24 #define LIBSPDM_CRYPTO_NID_SHA512 0x0003 25 #define LIBSPDM_CRYPTO_NID_SHA3_256 0x0004 26 #define LIBSPDM_CRYPTO_NID_SHA3_384 0x0005 27 #define LIBSPDM_CRYPTO_NID_SHA3_512 0x0006 28 #define LIBSPDM_CRYPTO_NID_SM3_256 0x0007 29 30 /* Signing */ 31 #define LIBSPDM_CRYPTO_NID_RSASSA2048 0x0101 32 #define LIBSPDM_CRYPTO_NID_RSASSA3072 0x0102 33 #define LIBSPDM_CRYPTO_NID_RSASSA4096 0x0103 34 #define LIBSPDM_CRYPTO_NID_RSAPSS2048 0x0104 35 #define LIBSPDM_CRYPTO_NID_RSAPSS3072 0x0105 36 #define LIBSPDM_CRYPTO_NID_RSAPSS4096 0x0106 37 #define LIBSPDM_CRYPTO_NID_ECDSA_NIST_P256 0x0107 38 #define LIBSPDM_CRYPTO_NID_ECDSA_NIST_P384 0x0108 39 #define LIBSPDM_CRYPTO_NID_ECDSA_NIST_P521 0x0109 40 #define LIBSPDM_CRYPTO_NID_SM2_DSA_P256 0x010A 41 #define LIBSPDM_CRYPTO_NID_EDDSA_ED25519 0x010B 42 #define LIBSPDM_CRYPTO_NID_EDDSA_ED448 0x010C 43 44 /* Key Exchange */ 45 #define LIBSPDM_CRYPTO_NID_FFDHE2048 0x0201 46 #define LIBSPDM_CRYPTO_NID_FFDHE3072 0x0202 47 #define LIBSPDM_CRYPTO_NID_FFDHE4096 0x0203 48 #define LIBSPDM_CRYPTO_NID_SECP256R1 0x0204 49 #define LIBSPDM_CRYPTO_NID_SECP384R1 0x0205 50 #define LIBSPDM_CRYPTO_NID_SECP521R1 0x0206 51 #define LIBSPDM_CRYPTO_NID_SM2_KEY_EXCHANGE_P256 0x0207 52 #define LIBSPDM_CRYPTO_NID_CURVE_X25519 0x0208 53 #define LIBSPDM_CRYPTO_NID_CURVE_X448 0x0209 54 55 /* AEAD */ 56 #define LIBSPDM_CRYPTO_NID_AES_128_GCM 0x0301 57 #define LIBSPDM_CRYPTO_NID_AES_256_GCM 0x0302 58 #define LIBSPDM_CRYPTO_NID_CHACHA20_POLY1305 0x0303 59 #define LIBSPDM_CRYPTO_NID_SM4_128_GCM 0x0304 60 61 /* X.509 v3 key usage extension flags. */ 62 #define LIBSPDM_CRYPTO_X509_KU_DIGITAL_SIGNATURE 0x80 /* bit 0 */ 63 #define LIBSPDM_CRYPTO_X509_KU_NON_REPUDIATION 0x40 /* bit 1 */ 64 #define LIBSPDM_CRYPTO_X509_KU_KEY_ENCIPHERMENT 0x20 /* bit 2 */ 65 #define LIBSPDM_CRYPTO_X509_KU_DATA_ENCIPHERMENT 0x10 /* bit 3 */ 66 #define LIBSPDM_CRYPTO_X509_KU_KEY_AGREEMENT 0x08 /* bit 4 */ 67 #define LIBSPDM_CRYPTO_X509_KU_KEY_CERT_SIGN 0x04 /* bit 5 */ 68 #define LIBSPDM_CRYPTO_X509_KU_CRL_SIGN 0x02 /* bit 6 */ 69 #define LIBSPDM_CRYPTO_X509_KU_ENCIPHER_ONLY 0x01 /* bit 7 */ 70 #define LIBSPDM_CRYPTO_X509_KU_DECIPHER_ONLY 0x8000 /* bit 8 */ 71 72 /* These constants comply with the DER encoded ASN.1 type tags. */ 73 #define LIBSPDM_CRYPTO_ASN1_BOOLEAN 0x01 74 #define LIBSPDM_CRYPTO_ASN1_INTEGER 0x02 75 #define LIBSPDM_CRYPTO_ASN1_BIT_STRING 0x03 76 #define LIBSPDM_CRYPTO_ASN1_OCTET_STRING 0x04 77 #define LIBSPDM_CRYPTO_ASN1_NULL 0x05 78 #define LIBSPDM_CRYPTO_ASN1_OID 0x06 79 #define LIBSPDM_CRYPTO_ASN1_UTF8_STRING 0x0C 80 #define LIBSPDM_CRYPTO_ASN1_SEQUENCE 0x10 81 #define LIBSPDM_CRYPTO_ASN1_SET 0x11 82 #define LIBSPDM_CRYPTO_ASN1_PRINTABLE_STRING 0x13 83 #define LIBSPDM_CRYPTO_ASN1_T61_STRING 0x14 84 #define LIBSPDM_CRYPTO_ASN1_IA5_STRING 0x16 85 #define LIBSPDM_CRYPTO_ASN1_UTC_TIME 0x17 86 #define LIBSPDM_CRYPTO_ASN1_GENERALIZED_TIME 0x18 87 #define LIBSPDM_CRYPTO_ASN1_UNIVERSAL_STRING 0x1C 88 #define LIBSPDM_CRYPTO_ASN1_BMP_STRING 0x1E 89 #define LIBSPDM_CRYPTO_ASN1_PRIMITIVE 0x00 90 #define LIBSPDM_CRYPTO_ASN1_CONSTRUCTED 0x20 91 #define LIBSPDM_CRYPTO_ASN1_CONTEXT_SPECIFIC 0x80 92 93 #define LIBSPDM_CRYPTO_ASN1_TAG_CLASS_MASK 0xC0 94 #define LIBSPDM_CRYPTO_ASN1_TAG_PC_MASK 0x20 95 #define LIBSPDM_CRYPTO_ASN1_TAG_VALUE_MASK 0x1F 96 97 #include "hal/library/cryptlib/cryptlib_hash.h" 98 #include "hal/library/cryptlib/cryptlib_mac.h" 99 #include "hal/library/cryptlib/cryptlib_aead.h" 100 #include "hal/library/cryptlib/cryptlib_cert.h" 101 #include "hal/library/cryptlib/cryptlib_hkdf.h" 102 #include "hal/library/cryptlib/cryptlib_rsa.h" 103 #include "hal/library/cryptlib/cryptlib_ec.h" 104 #include "hal/library/cryptlib/cryptlib_dh.h" 105 #include "hal/library/cryptlib/cryptlib_ecd.h" 106 #include "hal/library/cryptlib/cryptlib_sm2.h" 107 #include "hal/library/cryptlib/cryptlib_rng.h" 108 109 #endif /* CRYPTLIB_H */ 110