Add function returning gnutls_cipher_algorithm_t by corresponding OID.
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
gnutls_ocsp_status_request_get2@GNUTLS_3_6_3
gnutls_ocsp_status_request_get@GNUTLS_3_4
gnutls_ocsp_status_request_is_checked@GNUTLS_3_4
+gnutls_oid_to_cipher@GNUTLS_3_7_0
gnutls_oid_to_digest@GNUTLS_3_4
gnutls_oid_to_ecc_curve@GNUTLS_3_4
gnutls_oid_to_gost_paramset@GNUTLS_3_6_3
FUNCS += functions/gnutls_ocsp_status_request_get2.short
FUNCS += functions/gnutls_ocsp_status_request_is_checked
FUNCS += functions/gnutls_ocsp_status_request_is_checked.short
+FUNCS += functions/gnutls_oid_to_cipher
+FUNCS += functions/gnutls_oid_to_cipher.short
FUNCS += functions/gnutls_oid_to_digest
FUNCS += functions/gnutls_oid_to_digest.short
FUNCS += functions/gnutls_oid_to_ecc_curve
APIMANS += gnutls_ocsp_status_request_get.3
APIMANS += gnutls_ocsp_status_request_get2.3
APIMANS += gnutls_ocsp_status_request_is_checked.3
+APIMANS += gnutls_oid_to_cipher.3
APIMANS += gnutls_oid_to_digest.3
APIMANS += gnutls_oid_to_ecc_curve.3
APIMANS += gnutls_oid_to_gost_paramset.3
static const cipher_entry_st algorithms[] = {
{ .name = "AES-256-CBC",
.id = GNUTLS_CIPHER_AES_256_CBC,
+ .oid = AES_256_CBC_OID,
.blocksize = 16,
.keysize = 32,
.type = CIPHER_BLOCK,
.cipher_iv = 16},
{ .name = "AES-192-CBC",
.id = GNUTLS_CIPHER_AES_192_CBC,
+ .oid = AES_192_CBC_OID,
.blocksize = 16,
.keysize = 24,
.type = CIPHER_BLOCK,
.cipher_iv = 16},
{ .name = "3DES-CBC",
.id = GNUTLS_CIPHER_3DES_CBC,
+ .oid = DES_EDE3_CBC_OID,
.blocksize = 8,
.keysize = 24,
.type = CIPHER_BLOCK,
.cipher_iv = 8},
{ .name = "DES-CBC",
.id = GNUTLS_CIPHER_DES_CBC,
+ .oid = DES_CBC_OID,
.blocksize = 8,
.keysize = 8,
.type = CIPHER_BLOCK,
.cipher_iv = 8},
{ .name = "ARCFOUR-40",
.id = GNUTLS_CIPHER_ARCFOUR_40,
+ .oid = RC4_CBC_OID,
.blocksize = 1,
.keysize = 5,
.type = CIPHER_STREAM},
{ .name = "RC2-40",
.id = GNUTLS_CIPHER_RC2_40_CBC,
+ .oid = RC2_CBC_OID,
.blocksize = 8,
.keysize = 5,
.type = CIPHER_BLOCK,
return supported_ciphers;
}
+
+/**
+ * gnutls_oid_to_cipher:
+ * @oid: is an object identifier
+ *
+ * Converts a textual object identifier to a #gnutls_cipher_algorithm_t value.
+ *
+ * Returns: a #gnutls_cipher_algorithm_t id of the specified cipher
+ * algorithm, or %GNUTLS_CIPHER_UNKNOWN on failure.
+ *
+ * Since: 3.7.0
+ **/
+gnutls_cipher_algorithm_t gnutls_oid_to_cipher(const char *oid)
+{
+ GNUTLS_CIPHER_LOOP(
+ if (p->oid && strcmp(oid, p->oid) == 0) {
+ if (_gnutls_cipher_exists(p->id)) {
+ return p->id;
+ }
+ break;
+ }
+ );
+
+ return GNUTLS_CIPHER_UNKNOWN;
+}
typedef struct cipher_entry_st {
const char *name;
gnutls_cipher_algorithm_t id;
+ const char *oid;
uint16_t blocksize;
uint16_t keysize;
cipher_type_t type;
gnutls_oid_to_ecc_curve(const char *oid) __GNUTLS_CONST__;
gnutls_gost_paramset_t
gnutls_oid_to_gost_paramset(const char *oid) __GNUTLS_CONST__;
+gnutls_cipher_algorithm_t
+ gnutls_oid_to_cipher(const char *oid) __GNUTLS_CONST__;
/* list supported algorithms */
const gnutls_ecc_curve_t *
gnutls_handshake_set_read_function;
gnutls_handshake_set_secret_function;
gnutls_handshake_write;
+ gnutls_oid_to_cipher;
gnutls_pkcs7_digest;
gnutls_pkcs7_get_digest_algo;
gnutls_pkcs7_verify_digest;
#define PBES2_OID "1.2.840.113549.1.5.13"
#define PBKDF2_OID "1.2.840.113549.1.5.12"
-#define DES_EDE3_CBC_OID "1.2.840.113549.3.7"
-#define AES_128_CBC_OID "2.16.840.1.101.3.4.1.2"
-#define AES_192_CBC_OID "2.16.840.1.101.3.4.1.22"
-#define AES_256_CBC_OID "2.16.840.1.101.3.4.1.42"
-#define DES_CBC_OID "1.3.14.3.2.7"
/* oid_pbeWithSHAAnd3_KeyTripleDES_CBC */
#define PKCS12_PBE_3DES_SHA1_OID "1.2.840.113549.1.12.1.3"
#define HASH_OID_GOST_R_3411_94_CRYPTOPRO_PARAMS "1.2.643.2.2.30.1"
+#define RC2_CBC_OID "1.2.840.113549.3.2"
+#define RC4_CBC_OID "1.2.840.113549.3.4"
+#define DES_EDE3_CBC_OID "1.2.840.113549.3.7"
+#define AES_128_CBC_OID "2.16.840.1.101.3.4.1.2"
+#define AES_192_CBC_OID "2.16.840.1.101.3.4.1.22"
+#define AES_256_CBC_OID "2.16.840.1.101.3.4.1.42"
+#define DES_CBC_OID "1.3.14.3.2.7"
+
/* from rfc8479 */
#define OID_ATTR_PROV_SEED "1.3.6.1.4.1.2312.18.8.1"