summaryrefslogtreecommitdiff
path: root/lib/x509
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2016-10-21 17:05:38 +0300
committerDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2018-06-23 12:20:15 +0300
commit4bd42751adc13b47bcd2934112a93c6252404a43 (patch)
tree2a35e480f6c71cd1c784cffe593353450de74afd /lib/x509
parentd2d448d5e072eb14c7e4f5c9bd634c5ab138d7c9 (diff)
downloadgnutls-4bd42751adc13b47bcd2934112a93c6252404a43.tar.gz
Add few functions to support basic operations with GOST public keys
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Diffstat (limited to 'lib/x509')
-rw-r--r--lib/x509/common.c87
-rw-r--r--lib/x509/common.h7
2 files changed, 94 insertions, 0 deletions
diff --git a/lib/x509/common.c b/lib/x509/common.c
index f4310d7e36..a446186625 100644
--- a/lib/x509/common.c
+++ b/lib/x509/common.c
@@ -1813,3 +1813,90 @@ int _gnutls_check_if_sorted(gnutls_x509_crt_t * crt, int nr)
cleanup:
return ret;
}
+
+/**
+ * gnutls_gost_paramset_get_name:
+ * @param: is a GOST 28147 param set
+ *
+ * Convert a #gnutls_gost_paramset_t value to a string.
+ *
+ * Returns: a string that contains the name of the specified GOST param set,
+ * or %NULL.
+ *
+ * Since: 3.6.3
+ **/
+const char *gnutls_gost_paramset_get_name(gnutls_gost_paramset_t param)
+{
+ switch(param) {
+ case GNUTLS_GOST_PARAMSET_TC26_Z:
+ return "TC26-Z";
+ case GNUTLS_GOST_PARAMSET_CP_A:
+ return "CryptoPro-A";
+ case GNUTLS_GOST_PARAMSET_CP_B:
+ return "CryptoPro-B";
+ case GNUTLS_GOST_PARAMSET_CP_C:
+ return "CryptoPro-C";
+ case GNUTLS_GOST_PARAMSET_CP_D:
+ return "CryptoPro-D";
+ default:
+ gnutls_assert();
+ return "Unknown";
+ }
+}
+
+/**
+ * gnutls_gost_paramset_get_oid:
+ * @param: is a GOST 28147 param set
+ *
+ * Convert a #gnutls_gost_paramset_t value to its object identifier.
+ *
+ * Returns: a string that contains the object identifier of the specified GOST
+ * param set, or %NULL.
+ *
+ * Since: 3.6.3
+ **/
+const char *gnutls_gost_paramset_get_oid(gnutls_gost_paramset_t param)
+{
+ switch(param) {
+ case GNUTLS_GOST_PARAMSET_TC26_Z:
+ return GOST28147_89_TC26Z_OID;
+ case GNUTLS_GOST_PARAMSET_CP_A:
+ return GOST28147_89_CPA_OID;
+ case GNUTLS_GOST_PARAMSET_CP_B:
+ return GOST28147_89_CPB_OID;
+ case GNUTLS_GOST_PARAMSET_CP_C:
+ return GOST28147_89_CPC_OID;
+ case GNUTLS_GOST_PARAMSET_CP_D:
+ return GOST28147_89_CPD_OID;
+ default:
+ gnutls_assert();
+ return NULL;
+ }
+}
+
+/**
+ * gnutls_oid_to_gost_paramset:
+ * @oid: is an object identifier
+ *
+ * Converts a textual object identifier to a #gnutls_gost_paramset_t value.
+ *
+ * Returns: a #gnutls_gost_paramset_get_oid of the specified GOST 28147
+ * param st, or %GNUTLS_GOST_PARAMSET_UNKNOWN on failure.
+ *
+ * Since: 3.6.3
+ **/
+gnutls_gost_paramset_t gnutls_oid_to_gost_paramset(const char *oid)
+{
+ if (!strcmp(oid, GOST28147_89_TC26Z_OID))
+ return GNUTLS_GOST_PARAMSET_TC26_Z;
+ else if (!strcmp(oid, GOST28147_89_CPA_OID))
+ return GNUTLS_GOST_PARAMSET_CP_A;
+ else if (!strcmp(oid, GOST28147_89_CPB_OID))
+ return GNUTLS_GOST_PARAMSET_CP_B;
+ else if (!strcmp(oid, GOST28147_89_CPC_OID))
+ return GNUTLS_GOST_PARAMSET_CP_C;
+ else if (!strcmp(oid, GOST28147_89_CPD_OID))
+ return GNUTLS_GOST_PARAMSET_CP_D;
+ else
+ return gnutls_assert_val(GNUTLS_GOST_PARAMSET_UNKNOWN);
+}
diff --git a/lib/x509/common.h b/lib/x509/common.h
index d5c368a7b9..637121c2ee 100644
--- a/lib/x509/common.h
+++ b/lib/x509/common.h
@@ -103,6 +103,13 @@
#define KRB5_PRINCIPAL_OID "1.3.6.1.5.2.2"
#define PKIX1_RSA_PSS_MGF1_OID "1.2.840.113549.1.1.8"
+#define GOST28147_89_OID "1.2.643.2.2.21"
+#define GOST28147_89_TC26Z_OID "1.2.643.7.1.2.5.1.1"
+#define GOST28147_89_CPA_OID "1.2.643.2.2.31.1"
+#define GOST28147_89_CPB_OID "1.2.643.2.2.31.2"
+#define GOST28147_89_CPC_OID "1.2.643.2.2.31.3"
+#define GOST28147_89_CPD_OID "1.2.643.2.2.31.4"
+
#define ASN1_NULL "\x05\x00"
#define ASN1_NULL_SIZE 2