Announce openssl features only if actually supported
authorMartin Willi <martin@revosec.ch>
Wed, 21 Sep 2011 09:17:36 +0000 (11:17 +0200)
committerMartin Willi <martin@revosec.ch>
Fri, 14 Oct 2011 08:05:46 +0000 (10:05 +0200)
src/libstrongswan/plugins/openssl/openssl_plugin.c

index 89fa2cf..73c0c3b 100644 (file)
@@ -205,33 +205,62 @@ METHOD(plugin_t, get_features, int,
        static plugin_feature_t f[] = {
                /* crypters */
                PLUGIN_REGISTER(CRYPTER, openssl_crypter_create),
        static plugin_feature_t f[] = {
                /* crypters */
                PLUGIN_REGISTER(CRYPTER, openssl_crypter_create),
+#ifndef OPENSSL_NO_AES
                        PLUGIN_PROVIDE(CRYPTER, ENCR_AES_CBC, 12),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_AES_CBC, 24),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_AES_CBC, 32),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_AES_CBC, 12),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_AES_CBC, 24),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_AES_CBC, 32),
+#endif
+#ifndef OPENSSL_NO_CAMELLIA
                        PLUGIN_PROVIDE(CRYPTER, ENCR_CAMELLIA_CBC, 12),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_CAMELLIA_CBC, 24),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_CAMELLIA_CBC, 32),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_CAMELLIA_CBC, 12),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_CAMELLIA_CBC, 24),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_CAMELLIA_CBC, 32),
-                       PLUGIN_PROVIDE(CRYPTER, ENCR_3DES, 24),
+#endif
+#ifndef OPENSSL_NO_RC5
                        PLUGIN_PROVIDE(CRYPTER, ENCR_RC5, 0),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_RC5, 0),
+#endif
+#ifndef OPENSSL_NO_CAST
                        PLUGIN_PROVIDE(CRYPTER, ENCR_CAST, 0),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_CAST, 0),
+#endif
+#ifndef OPENSSL_NO_BLOWFISH
                        PLUGIN_PROVIDE(CRYPTER, ENCR_BLOWFISH, 0),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_BLOWFISH, 0),
+#endif
+#ifndef OPENSSL_NO_IDEA
                        PLUGIN_PROVIDE(CRYPTER, ENCR_IDEA, 16),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_IDEA, 16),
+#endif
+#ifndef OPENSSL_NO_DES
+                       PLUGIN_PROVIDE(CRYPTER, ENCR_3DES, 24),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_DES, 8),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_DES_ECB, 8),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_DES, 8),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_DES_ECB, 8),
+#endif
                        PLUGIN_PROVIDE(CRYPTER, ENCR_NULL, 0),
                /* hashers */
                PLUGIN_REGISTER(HASHER, openssl_hasher_create),
                        PLUGIN_PROVIDE(CRYPTER, ENCR_NULL, 0),
                /* hashers */
                PLUGIN_REGISTER(HASHER, openssl_hasher_create),
+#ifndef OPENSSL_NO_SHA1
                        PLUGIN_PROVIDE(HASHER, HASH_SHA1),
                        PLUGIN_PROVIDE(HASHER, HASH_SHA1),
+#endif
+#ifndef OPENSSL_NO_MD2
                        PLUGIN_PROVIDE(HASHER, HASH_MD2),
                        PLUGIN_PROVIDE(HASHER, HASH_MD2),
+#endif
+#ifndef OPENSSL_NO_MD4
                        PLUGIN_PROVIDE(HASHER, HASH_MD4),
                        PLUGIN_PROVIDE(HASHER, HASH_MD4),
+#endif
+#ifndef OPENSSL_NO_MD5
                        PLUGIN_PROVIDE(HASHER, HASH_MD5),
                        PLUGIN_PROVIDE(HASHER, HASH_MD5),
+#endif
+#ifndef OPENSSL_NO_SHA256
                        PLUGIN_PROVIDE(HASHER, HASH_SHA224),
                        PLUGIN_PROVIDE(HASHER, HASH_SHA256),
                        PLUGIN_PROVIDE(HASHER, HASH_SHA224),
                        PLUGIN_PROVIDE(HASHER, HASH_SHA256),
+#endif
+#ifndef OPENSSL_NO_SHA512
                        PLUGIN_PROVIDE(HASHER, HASH_SHA384),
                        PLUGIN_PROVIDE(HASHER, HASH_SHA512),
                        PLUGIN_PROVIDE(HASHER, HASH_SHA384),
                        PLUGIN_PROVIDE(HASHER, HASH_SHA512),
+#endif
+#ifndef OPENSSL_NO_SHA1
                /* keyed sha1 hasher (aka prf) */
                PLUGIN_REGISTER(PRF, openssl_sha1_prf_create),
                        PLUGIN_PROVIDE(PRF, PRF_KEYED_SHA1),
                /* keyed sha1 hasher (aka prf) */
                PLUGIN_REGISTER(PRF, openssl_sha1_prf_create),
                        PLUGIN_PROVIDE(PRF, PRF_KEYED_SHA1),
+#endif
+#ifndef OPENSSL_NO_DH
                /* MODP DH groups */
                PLUGIN_REGISTER(DH, openssl_diffie_hellman_create),
                        PLUGIN_PROVIDE(DH, MODP_2048_BIT),
                /* MODP DH groups */
                PLUGIN_REGISTER(DH, openssl_diffie_hellman_create),
                        PLUGIN_PROVIDE(DH, MODP_2048_BIT),
@@ -246,7 +275,9 @@ METHOD(plugin_t, get_features, int,
                        PLUGIN_PROVIDE(DH, MODP_1024_160),
                        PLUGIN_PROVIDE(DH, MODP_768_BIT),
                        PLUGIN_PROVIDE(DH, MODP_CUSTOM),
                        PLUGIN_PROVIDE(DH, MODP_1024_160),
                        PLUGIN_PROVIDE(DH, MODP_768_BIT),
                        PLUGIN_PROVIDE(DH, MODP_CUSTOM),
-               /* private/public key loading */
+#endif
+#ifndef OPENSSL_NO_RSA
+               /* RSA private/public key loading */
                PLUGIN_REGISTER(PRIVKEY, openssl_rsa_private_key_load, TRUE),
                        PLUGIN_PROVIDE(PRIVKEY, KEY_RSA),
                PLUGIN_REGISTER(PRIVKEY, openssl_rsa_private_key_connect, FALSE),
                PLUGIN_REGISTER(PRIVKEY, openssl_rsa_private_key_load, TRUE),
                        PLUGIN_PROVIDE(PRIVKEY, KEY_RSA),
                PLUGIN_REGISTER(PRIVKEY, openssl_rsa_private_key_connect, FALSE),
@@ -259,27 +290,36 @@ METHOD(plugin_t, get_features, int,
                        PLUGIN_PROVIDE(PUBKEY, KEY_ANY),
                /* signature/encryption schemes */
                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_RSA_EMSA_PKCS1_NULL),
                        PLUGIN_PROVIDE(PUBKEY, KEY_ANY),
                /* signature/encryption schemes */
                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_RSA_EMSA_PKCS1_NULL),
+               PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_RSA_EMSA_PKCS1_NULL),
+#ifndef OPENSSL_NO_SHA1
                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_RSA_EMSA_PKCS1_SHA1),
                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_RSA_EMSA_PKCS1_SHA1),
+               PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_RSA_EMSA_PKCS1_SHA1),
+#endif
+#ifndef OPENSSL_NO_SHA256
                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_RSA_EMSA_PKCS1_SHA224),
                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_RSA_EMSA_PKCS1_SHA256),
                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_RSA_EMSA_PKCS1_SHA224),
                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_RSA_EMSA_PKCS1_SHA256),
-               PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_RSA_EMSA_PKCS1_SHA384),
-               PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_RSA_EMSA_PKCS1_SHA512),
-               PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_RSA_EMSA_PKCS1_MD5),
-               PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_RSA_EMSA_PKCS1_NULL),
-               PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_RSA_EMSA_PKCS1_SHA1),
                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_RSA_EMSA_PKCS1_SHA224),
                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_RSA_EMSA_PKCS1_SHA256),
                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_RSA_EMSA_PKCS1_SHA224),
                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_RSA_EMSA_PKCS1_SHA256),
+#endif
+#ifndef OPENSSL_NO_SHA512
+               PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_RSA_EMSA_PKCS1_SHA384),
+               PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_RSA_EMSA_PKCS1_SHA512),
                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_RSA_EMSA_PKCS1_SHA384),
                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_RSA_EMSA_PKCS1_SHA512),
                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_RSA_EMSA_PKCS1_SHA384),
                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_RSA_EMSA_PKCS1_SHA512),
+#endif
+#ifndef OPENSSL_NO_MD5
+               PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_RSA_EMSA_PKCS1_MD5),
                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_RSA_EMSA_PKCS1_MD5),
                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_RSA_EMSA_PKCS1_MD5),
+#endif
                PLUGIN_PROVIDE(PRIVKEY_DECRYPT, ENCRYPT_RSA_PKCS1),
                PLUGIN_PROVIDE(PUBKEY_ENCRYPT, ENCRYPT_RSA_PKCS1),
                PLUGIN_PROVIDE(PRIVKEY_DECRYPT, ENCRYPT_RSA_PKCS1),
                PLUGIN_PROVIDE(PUBKEY_ENCRYPT, ENCRYPT_RSA_PKCS1),
+#endif /* OPENSSL_NO_RSA */
                /* certificate/CRL loading */
                PLUGIN_REGISTER(CERT_DECODE, openssl_x509_load, TRUE),
                        PLUGIN_PROVIDE(CERT_DECODE, CERT_X509),
                PLUGIN_REGISTER(CERT_DECODE, openssl_crl_load, TRUE),
                        PLUGIN_PROVIDE(CERT_DECODE, CERT_X509_CRL),
                /* certificate/CRL loading */
                PLUGIN_REGISTER(CERT_DECODE, openssl_x509_load, TRUE),
                        PLUGIN_PROVIDE(CERT_DECODE, CERT_X509),
                PLUGIN_REGISTER(CERT_DECODE, openssl_crl_load, TRUE),
                        PLUGIN_PROVIDE(CERT_DECODE, CERT_X509_CRL),
-#ifndef OPENSSL_NO_EC
+#ifndef OPENSSL_NO_ECDH
                /* EC DH groups */
                PLUGIN_REGISTER(DH, openssl_ec_diffie_hellman_create),
                        PLUGIN_PROVIDE(DH, ECP_256_BIT),
                /* EC DH groups */
                PLUGIN_REGISTER(DH, openssl_ec_diffie_hellman_create),
                        PLUGIN_PROVIDE(DH, ECP_256_BIT),
@@ -287,6 +327,8 @@ METHOD(plugin_t, get_features, int,
                        PLUGIN_PROVIDE(DH, ECP_521_BIT),
                        PLUGIN_PROVIDE(DH, ECP_224_BIT),
                        PLUGIN_PROVIDE(DH, ECP_192_BIT),
                        PLUGIN_PROVIDE(DH, ECP_521_BIT),
                        PLUGIN_PROVIDE(DH, ECP_224_BIT),
                        PLUGIN_PROVIDE(DH, ECP_192_BIT),
+#endif
+#ifndef OPENSSL_NO_ECDSA
                /* EC private/public key loading */
                PLUGIN_REGISTER(PRIVKEY, openssl_ec_private_key_load, TRUE),
                        PLUGIN_PROVIDE(PRIVKEY, KEY_ECDSA),
                /* EC private/public key loading */
                PLUGIN_REGISTER(PRIVKEY, openssl_ec_private_key_load, TRUE),
                        PLUGIN_PROVIDE(PRIVKEY, KEY_ECDSA),
@@ -296,22 +338,28 @@ METHOD(plugin_t, get_features, int,
                        PLUGIN_PROVIDE(PUBKEY, KEY_ECDSA),
                /* signature encryption schemes */
                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_ECDSA_WITH_NULL),
                        PLUGIN_PROVIDE(PUBKEY, KEY_ECDSA),
                /* signature encryption schemes */
                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_ECDSA_WITH_NULL),
+               PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_ECDSA_WITH_NULL),
+#ifndef OPENSSL_NO_SHA1
                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_ECDSA_WITH_SHA1_DER),
                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_ECDSA_WITH_SHA1_DER),
+               PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_ECDSA_WITH_SHA1_DER),
+#endif
+#ifndef OPENSSL_NO_SHA256
                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_ECDSA_WITH_SHA256_DER),
                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_ECDSA_WITH_SHA256_DER),
+               PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_ECDSA_WITH_SHA256_DER),
+               PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_ECDSA_256),
+               PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_ECDSA_256),
+#endif
+#ifndef OPENSSL_NO_SHA512
                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_ECDSA_WITH_SHA384_DER),
                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_ECDSA_WITH_SHA512_DER),
                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_ECDSA_WITH_SHA384_DER),
                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_ECDSA_WITH_SHA512_DER),
-               PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_ECDSA_256),
-               PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_ECDSA_384),
-               PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_ECDSA_521),
-               PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_ECDSA_WITH_NULL),
-               PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_ECDSA_WITH_SHA1_DER),
-               PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_ECDSA_WITH_SHA256_DER),
                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_ECDSA_WITH_SHA384_DER),
                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_ECDSA_WITH_SHA512_DER),
                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_ECDSA_WITH_SHA384_DER),
                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_ECDSA_WITH_SHA512_DER),
-               PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_ECDSA_256),
+               PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_ECDSA_384),
+               PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_ECDSA_521),
                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_ECDSA_384),
                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_ECDSA_521),
                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_ECDSA_384),
                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_ECDSA_521),
-#endif /* OPENSSL_NO_EC */
+#endif
+#endif /* OPENSSL_NO_ECDSA */
        };
        *features = f;
        return countof(f);
        };
        *features = f;
        return countof(f);