]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
support generation of EC certificates
authorMartin Willi <martin@strongswan.org>
Thu, 27 Aug 2009 11:34:06 +0000 (13:34 +0200)
committerMartin Willi <martin@strongswan.org>
Thu, 27 Aug 2009 11:59:30 +0000 (13:59 +0200)
src/libstrongswan/plugins/x509/x509_cert.c

index a897048a23e3e699159d48201f9715213539c235..8a68e9df06f85fc2e31568c3bc1a8e731f0d13d4 100644 (file)
@@ -1208,7 +1208,7 @@ static bool generate(private_builder_t *this)
 {
        chunk_t extensions = chunk_empty;
        identification_t *issuer, *subject;
-       chunk_t key_info, key;
+       chunk_t key_info;
        signature_scheme_t scheme;
        hasher_t *hasher;
        
@@ -1241,32 +1241,25 @@ static bool generate(private_builder_t *this)
        }
        this->cert->flags = this->flags;
        
+       /* select signature scheme. TODO: support other hashes. */
        switch (this->sign_key->get_type(this->sign_key))
        {
                case KEY_RSA:
                        this->cert->algorithm = OID_SHA1_WITH_RSA;
                        scheme = SIGN_RSA_EMSA_PKCS1_SHA1;
                        break;
+               case KEY_ECDSA:
+                       scheme = SIGN_ECDSA_WITH_SHA1;
+                       this->cert->algorithm = OID_ECDSA_WITH_SHA1;
+                       break;
                default:
                        return FALSE;
        }
-       
-       switch (this->cert->public_key->get_type(this->cert->public_key))
+       if (!this->cert->public_key->get_encoding(this->cert->public_key,
+                                                                                         KEY_PUB_SPKI_ASN1_DER, &key_info))
        {
-               case KEY_RSA:
-                       if (!this->cert->public_key->get_encoding(this->cert->public_key,
-                                                                                                         KEY_PUB_ASN1_DER, &key))
-                       {
-                               return FALSE;
-                       }
-                       key_info = asn1_wrap(ASN1_SEQUENCE, "mm",
-                                                       asn1_algorithmIdentifier(OID_RSA_ENCRYPTION),
-                                                       asn1_bitstring("m", key));
-                       break;
-               default:
-                       return FALSE;
+               return FALSE;
        }
-       
        if (this->cert->subjectAltNames->get_count(this->cert->subjectAltNames))
        {
                /* TODO: encode subjectAltNames */