]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
ecc: Add function to convert ec_curve_t to a known OID index
authorTobias Brunner <tobias@strongswan.org>
Mon, 16 Sep 2013 12:58:56 +0000 (14:58 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 16 Sep 2013 13:23:10 +0000 (15:23 +0200)
src/libstrongswan/crypto/ec_params.c
src/libstrongswan/crypto/ec_params.h

index 05c110f2ab1f6f4258d868470989d96dbada819b..13c3a360244ec2ff74d4d31fe634e3f39d79eb30 100644 (file)
@@ -328,6 +328,36 @@ ec_curve_t ec_curve_from_oid(int oid)
        }
 }
 
+/*
+ * See header
+ */
+int ec_curve_to_oid(ec_curve_t curve)
+{
+       switch (curve)
+       {
+               case ECC_NIST_192:
+                       return OID_PRIME192V1;
+               case ECC_NIST_224:
+                       return OID_SECT224R1;
+               case ECC_NIST_256:
+                       return OID_PRIME256V1;
+               case ECC_NIST_384:
+                       return OID_SECT384R1;
+               case ECC_NIST_521:
+                       return OID_SECT521R1;
+               case ECC_BP_224:
+                       return OID_BRAINPOOL_P224R1;
+               case ECC_BP_256:
+                       return OID_BRAINPOOL_P256R1;
+               case ECC_BP_384:
+                       return OID_BRAINPOOL_P384R1;
+               case ECC_BP_512:
+                       return OID_BRAINPOOL_P512R1;
+               default:
+                       return OID_UNKNOWN;
+       }
+}
+
 /*
  * See header
  */
index f33fca4b92721a0e47d585b22d690ca4f919759e..9ee3982516bb0cb3d1f43983146d2cfba54f3899 100644 (file)
@@ -102,6 +102,14 @@ struct ec_params_t {
  */
 ec_curve_t ec_curve_from_oid(int oid);
 
+/**
+ * Get the OID for the given curve identifier.
+ *
+ * @param group                        curve
+ * @return                             OID or OID_UNKNOWN
+ */
+int ec_curve_to_oid(ec_curve_t curve);
+
 /**
  * Get the curve identifier for the specified DH group.
  *