summaryrefslogtreecommitdiff
path: root/src/libstrongswan
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan')
-rw-r--r--src/libstrongswan/Makefile.am24
-rw-r--r--src/libstrongswan/Makefile.in186
-rw-r--r--src/libstrongswan/asn1/asn1.c94
-rw-r--r--src/libstrongswan/asn1/asn1.h16
-rw-r--r--src/libstrongswan/asn1/asn1_parser.c66
-rw-r--r--src/libstrongswan/asn1/oid.c715
-rw-r--r--src/libstrongswan/asn1/oid.h178
-rw-r--r--src/libstrongswan/asn1/oid.txt17
-rw-r--r--src/libstrongswan/credentials/auth_cfg.c155
-rw-r--r--src/libstrongswan/credentials/auth_cfg.h8
-rw-r--r--src/libstrongswan/credentials/builder.c8
-rw-r--r--src/libstrongswan/credentials/builder.h18
-rw-r--r--src/libstrongswan/credentials/cert_validator.h7
-rw-r--r--src/libstrongswan/credentials/certificates/crl.h15
-rw-r--r--src/libstrongswan/credentials/certificates/x509.h89
-rw-r--r--src/libstrongswan/credentials/credential_manager.c90
-rw-r--r--src/libstrongswan/credentials/sets/auth_cfg_wrapper.c3
-rw-r--r--src/libstrongswan/credentials/sets/mem_cred.c240
-rw-r--r--src/libstrongswan/credentials/sets/mem_cred.h50
-rw-r--r--src/libstrongswan/crypto/crypto_factory.c133
-rw-r--r--src/libstrongswan/crypto/crypto_factory.h31
-rw-r--r--src/libstrongswan/crypto/crypto_tester.c166
-rw-r--r--src/libstrongswan/crypto/crypto_tester.h16
-rw-r--r--src/libstrongswan/eap/eap.h2
-rw-r--r--src/libstrongswan/enum.c2
-rw-r--r--src/libstrongswan/fetcher/fetcher_manager.c4
-rw-r--r--src/libstrongswan/integrity_checker.c62
-rw-r--r--src/libstrongswan/plugins/aes/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/aes/aes_plugin.c4
-rw-r--r--src/libstrongswan/plugins/af_alg/Makefile.am20
-rw-r--r--src/libstrongswan/plugins/af_alg/Makefile.in612
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_crypter.c237
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_crypter.h54
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_hasher.c170
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_hasher.h52
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_ops.c226
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_ops.h92
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_plugin.c74
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_plugin.h42
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_prf.c211
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_prf.h52
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_signer.c206
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_signer.h52
-rw-r--r--src/libstrongswan/plugins/agent/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/blowfish/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/blowfish/blowfish_plugin.c4
-rw-r--r--src/libstrongswan/plugins/ccm/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/ccm/ccm_plugin.c37
-rw-r--r--src/libstrongswan/plugins/constraints/Makefile.am16
-rw-r--r--src/libstrongswan/plugins/constraints/Makefile.in604
-rw-r--r--src/libstrongswan/plugins/constraints/constraints_plugin.c65
-rw-r--r--src/libstrongswan/plugins/constraints/constraints_plugin.h42
-rw-r--r--src/libstrongswan/plugins/constraints/constraints_validator.c578
-rw-r--r--src/libstrongswan/plugins/constraints/constraints_validator.h49
-rw-r--r--src/libstrongswan/plugins/ctr/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/ctr/ctr_plugin.c22
-rw-r--r--src/libstrongswan/plugins/curl/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/curl/curl_fetcher.c16
-rw-r--r--src/libstrongswan/plugins/curl/curl_plugin.c16
-rw-r--r--src/libstrongswan/plugins/des/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/des/des_plugin.c8
-rw-r--r--src/libstrongswan/plugins/dnskey/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/dnskey/dnskey_plugin.c19
-rw-r--r--src/libstrongswan/plugins/fips_prf/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/fips_prf/fips_prf.c55
-rw-r--r--src/libstrongswan/plugins/fips_prf/fips_prf_plugin.c28
-rw-r--r--src/libstrongswan/plugins/gcm/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/gcm/gcm_plugin.c20
-rw-r--r--src/libstrongswan/plugins/gcrypt/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/gcrypt/gcrypt_plugin.c68
-rw-r--r--src/libstrongswan/plugins/gmp/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/gmp/gmp_plugin.c26
-rw-r--r--src/libstrongswan/plugins/hmac/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/hmac/hmac_plugin.c88
-rw-r--r--src/libstrongswan/plugins/ldap/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/ldap/ldap_fetcher.c35
-rw-r--r--src/libstrongswan/plugins/ldap/ldap_plugin.c16
-rw-r--r--src/libstrongswan/plugins/md4/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/md4/md4_plugin.c20
-rw-r--r--src/libstrongswan/plugins/md5/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/md5/md5_plugin.c20
-rw-r--r--src/libstrongswan/plugins/mysql/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/mysql/mysql_database.c40
-rw-r--r--src/libstrongswan/plugins/mysql/mysql_plugin.c15
-rw-r--r--src/libstrongswan/plugins/openssl/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/openssl/openssl_crl.c11
-rw-r--r--src/libstrongswan/plugins/openssl/openssl_plugin.c74
-rw-r--r--src/libstrongswan/plugins/openssl/openssl_x509.c100
-rw-r--r--src/libstrongswan/plugins/padlock/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/padlock/padlock_plugin.c12
-rw-r--r--src/libstrongswan/plugins/pem/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/pem/pem_encoder.c2
-rw-r--r--src/libstrongswan/plugins/pem/pem_plugin.c18
-rw-r--r--src/libstrongswan/plugins/pgp/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/pgp/pgp_plugin.c21
-rw-r--r--src/libstrongswan/plugins/pkcs1/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/pkcs1/pkcs1_plugin.c16
-rw-r--r--src/libstrongswan/plugins/pkcs11/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/pkcs11/pkcs11_creds.c23
-rw-r--r--src/libstrongswan/plugins/pkcs11/pkcs11_library.c67
-rw-r--r--src/libstrongswan/plugins/pkcs11/pkcs11_library.h21
-rw-r--r--src/libstrongswan/plugins/pkcs11/pkcs11_manager.c5
-rw-r--r--src/libstrongswan/plugins/pkcs11/pkcs11_plugin.c14
-rw-r--r--src/libstrongswan/plugins/pkcs11/pkcs11_private_key.c18
-rw-r--r--src/libstrongswan/plugins/plugin_loader.c111
-rw-r--r--src/libstrongswan/plugins/pubkey/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/pubkey/pubkey_plugin.c18
-rw-r--r--src/libstrongswan/plugins/random/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/random/random_plugin.c22
-rw-r--r--src/libstrongswan/plugins/random/random_rng.c37
-rw-r--r--src/libstrongswan/plugins/revocation/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/revocation/revocation_validator.c279
-rw-r--r--src/libstrongswan/plugins/sha1/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/sha1/sha1_plugin.c22
-rw-r--r--src/libstrongswan/plugins/sha2/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/sha2/sha2_plugin.c26
-rw-r--r--src/libstrongswan/plugins/soup/Makefile.am16
-rw-r--r--src/libstrongswan/plugins/soup/Makefile.in601
-rw-r--r--src/libstrongswan/plugins/soup/soup_fetcher.c159
-rw-r--r--src/libstrongswan/plugins/soup/soup_fetcher.h44
-rw-r--r--src/libstrongswan/plugins/soup/soup_plugin.c72
-rw-r--r--src/libstrongswan/plugins/soup/soup_plugin.h (renamed from src/libstrongswan/credentials/certificates/x509.c)40
-rw-r--r--src/libstrongswan/plugins/sqlite/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/sqlite/sqlite_database.c45
-rw-r--r--src/libstrongswan/plugins/sqlite/sqlite_plugin.c18
-rw-r--r--src/libstrongswan/plugins/test_vectors/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/test_vectors/test_vectors_plugin.c16
-rw-r--r--src/libstrongswan/plugins/x509/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/x509/x509_cert.c1192
-rw-r--r--src/libstrongswan/plugins/x509/x509_crl.c173
-rw-r--r--src/libstrongswan/plugins/x509/x509_plugin.c16
-rw-r--r--src/libstrongswan/plugins/xcbc/Makefile.in4
-rw-r--r--src/libstrongswan/plugins/xcbc/xcbc_plugin.c30
-rw-r--r--src/libstrongswan/printf_hook.c24
-rw-r--r--src/libstrongswan/processing/processor.c2
-rw-r--r--src/libstrongswan/selectors/traffic_selector.c6
-rw-r--r--src/libstrongswan/settings.c838
-rw-r--r--src/libstrongswan/settings.h171
-rw-r--r--src/libstrongswan/utils.c8
-rw-r--r--src/libstrongswan/utils.h17
-rw-r--r--src/libstrongswan/utils/backtrace.c14
-rw-r--r--src/libstrongswan/utils/backtrace.h9
-rw-r--r--src/libstrongswan/utils/hashtable.c3
-rw-r--r--src/libstrongswan/utils/host.c39
-rw-r--r--src/libstrongswan/utils/host.h9
-rw-r--r--src/libstrongswan/utils/identification.c10
-rw-r--r--src/libstrongswan/utils/leak_detective.c33
-rw-r--r--src/libstrongswan/utils/optionsfrom.c30
148 files changed, 9097 insertions, 1989 deletions
diff --git a/src/libstrongswan/Makefile.am b/src/libstrongswan/Makefile.am
index 2ab8aa636..6a29d8eea 100644
--- a/src/libstrongswan/Makefile.am
+++ b/src/libstrongswan/Makefile.am
@@ -30,8 +30,7 @@ credentials/keys/private_key.c credentials/keys/private_key.h \
credentials/keys/public_key.c credentials/keys/public_key.h \
credentials/keys/shared_key.c credentials/keys/shared_key.h \
credentials/certificates/certificate.c credentials/certificates/certificate.h \
-credentials/certificates/x509.h credentials/certificates/x509.c \
-credentials/certificates/ac.h \
+credentials/certificates/x509.h credentials/certificates/ac.h \
credentials/certificates/crl.h credentials/certificates/crl.c \
credentials/certificates/pkcs10.h \
credentials/certificates/ocsp_request.h \
@@ -136,6 +135,13 @@ else
SUBDIRS = .
endif
+if USE_AF_ALG
+ SUBDIRS += plugins/af_alg
+if MONOLITHIC
+ libstrongswan_la_LIBADD += plugins/af_alg/libstrongswan-af-alg.la
+endif
+endif
+
if USE_AES
SUBDIRS += plugins/aes
if MONOLITHIC
@@ -227,6 +233,13 @@ if MONOLITHIC
endif
endif
+if USE_CONSTRAINTS
+ SUBDIRS += plugins/constraints
+if MONOLITHIC
+ libstrongswan_la_LIBADD += plugins/constraints/libstrongswan-constraints.la
+endif
+endif
+
if USE_PUBKEY
SUBDIRS += plugins/pubkey
if MONOLITHIC
@@ -269,6 +282,13 @@ if MONOLITHIC
endif
endif
+if USE_SOUP
+ SUBDIRS += plugins/soup
+if MONOLITHIC
+ libstrongswan_la_LIBADD += plugins/soup/libstrongswan-soup.la
+endif
+endif
+
if USE_LDAP
SUBDIRS += plugins/ldap
if MONOLITHIC
diff --git a/src/libstrongswan/Makefile.in b/src/libstrongswan/Makefile.in
index 8be6dd9b8..76b4f70c6 100644
--- a/src/libstrongswan/Makefile.in
+++ b/src/libstrongswan/Makefile.in
@@ -44,70 +44,76 @@ host_triplet = @host@
@USE_INTEGRITY_TEST_TRUE@ integrity_checker.c integrity_checker.h
@USE_VSTR_TRUE@am__append_6 = -lvstr
-@USE_AES_TRUE@am__append_7 = plugins/aes
-@MONOLITHIC_TRUE@@USE_AES_TRUE@am__append_8 = plugins/aes/libstrongswan-aes.la
-@USE_DES_TRUE@am__append_9 = plugins/des
-@MONOLITHIC_TRUE@@USE_DES_TRUE@am__append_10 = plugins/des/libstrongswan-des.la
-@USE_BLOWFISH_TRUE@am__append_11 = plugins/blowfish
-@MONOLITHIC_TRUE@@USE_BLOWFISH_TRUE@am__append_12 = plugins/blowfish/libstrongswan-blowfish.la
-@USE_MD4_TRUE@am__append_13 = plugins/md4
-@MONOLITHIC_TRUE@@USE_MD4_TRUE@am__append_14 = plugins/md4/libstrongswan-md4.la
-@USE_MD5_TRUE@am__append_15 = plugins/md5
-@MONOLITHIC_TRUE@@USE_MD5_TRUE@am__append_16 = plugins/md5/libstrongswan-md5.la
-@USE_SHA1_TRUE@am__append_17 = plugins/sha1
-@MONOLITHIC_TRUE@@USE_SHA1_TRUE@am__append_18 = plugins/sha1/libstrongswan-sha1.la
-@USE_SHA2_TRUE@am__append_19 = plugins/sha2
-@MONOLITHIC_TRUE@@USE_SHA2_TRUE@am__append_20 = plugins/sha2/libstrongswan-sha2.la
-@USE_GMP_TRUE@am__append_21 = plugins/gmp
-@MONOLITHIC_TRUE@@USE_GMP_TRUE@am__append_22 = plugins/gmp/libstrongswan-gmp.la
-@USE_RANDOM_TRUE@am__append_23 = plugins/random
-@MONOLITHIC_TRUE@@USE_RANDOM_TRUE@am__append_24 = plugins/random/libstrongswan-random.la
-@USE_HMAC_TRUE@am__append_25 = plugins/hmac
-@MONOLITHIC_TRUE@@USE_HMAC_TRUE@am__append_26 = plugins/hmac/libstrongswan-hmac.la
-@USE_XCBC_TRUE@am__append_27 = plugins/xcbc
-@MONOLITHIC_TRUE@@USE_XCBC_TRUE@am__append_28 = plugins/xcbc/libstrongswan-xcbc.la
-@USE_X509_TRUE@am__append_29 = plugins/x509
-@MONOLITHIC_TRUE@@USE_X509_TRUE@am__append_30 = plugins/x509/libstrongswan-x509.la
-@USE_REVOCATION_TRUE@am__append_31 = plugins/revocation
-@MONOLITHIC_TRUE@@USE_REVOCATION_TRUE@am__append_32 = plugins/revocation/libstrongswan-revocation.la
-@USE_PUBKEY_TRUE@am__append_33 = plugins/pubkey
-@MONOLITHIC_TRUE@@USE_PUBKEY_TRUE@am__append_34 = plugins/pubkey/libstrongswan-pubkey.la
-@USE_PKCS1_TRUE@am__append_35 = plugins/pkcs1
-@MONOLITHIC_TRUE@@USE_PKCS1_TRUE@am__append_36 = plugins/pkcs1/libstrongswan-pkcs1.la
-@USE_PGP_TRUE@am__append_37 = plugins/pgp
-@MONOLITHIC_TRUE@@USE_PGP_TRUE@am__append_38 = plugins/pgp/libstrongswan-pgp.la
-@USE_DNSKEY_TRUE@am__append_39 = plugins/dnskey
-@MONOLITHIC_TRUE@@USE_DNSKEY_TRUE@am__append_40 = plugins/dnskey/libstrongswan-dnskey.la
-@USE_PEM_TRUE@am__append_41 = plugins/pem
-@MONOLITHIC_TRUE@@USE_PEM_TRUE@am__append_42 = plugins/pem/libstrongswan-pem.la
-@USE_CURL_TRUE@am__append_43 = plugins/curl
-@MONOLITHIC_TRUE@@USE_CURL_TRUE@am__append_44 = plugins/curl/libstrongswan-curl.la
-@USE_LDAP_TRUE@am__append_45 = plugins/ldap
-@MONOLITHIC_TRUE@@USE_LDAP_TRUE@am__append_46 = plugins/ldap/libstrongswan-ldap.la
-@USE_MYSQL_TRUE@am__append_47 = plugins/mysql
-@MONOLITHIC_TRUE@@USE_MYSQL_TRUE@am__append_48 = plugins/mysql/libstrongswan-mysql.la
-@USE_SQLITE_TRUE@am__append_49 = plugins/sqlite
-@MONOLITHIC_TRUE@@USE_SQLITE_TRUE@am__append_50 = plugins/sqlite/libstrongswan-sqlite.la
-@USE_PADLOCK_TRUE@am__append_51 = plugins/padlock
-@MONOLITHIC_TRUE@@USE_PADLOCK_TRUE@am__append_52 = plugins/padlock/libstrongswan-padlock.la
-@USE_OPENSSL_TRUE@am__append_53 = plugins/openssl
-@MONOLITHIC_TRUE@@USE_OPENSSL_TRUE@am__append_54 = plugins/openssl/libstrongswan-openssl.la
-@USE_GCRYPT_TRUE@am__append_55 = plugins/gcrypt
-@MONOLITHIC_TRUE@@USE_GCRYPT_TRUE@am__append_56 = plugins/gcrypt/libstrongswan-gcrypt.la
-@USE_FIPS_PRF_TRUE@am__append_57 = plugins/fips_prf
-@MONOLITHIC_TRUE@@USE_FIPS_PRF_TRUE@am__append_58 = plugins/fips_prf/libstrongswan-fips-prf.la
-@USE_AGENT_TRUE@am__append_59 = plugins/agent
-@MONOLITHIC_TRUE@@USE_AGENT_TRUE@am__append_60 = plugins/agent/libstrongswan-agent.la
-@USE_PKCS11_TRUE@am__append_61 = plugins/pkcs11
-@MONOLITHIC_TRUE@@USE_PKCS11_TRUE@am__append_62 = plugins/pkcs11/libstrongswan-pkcs11.la
-@USE_CTR_TRUE@am__append_63 = plugins/ctr
-@MONOLITHIC_TRUE@@USE_CTR_TRUE@am__append_64 = plugins/ctr/libstrongswan-ctr.la
-@USE_CCM_TRUE@am__append_65 = plugins/ccm
-@MONOLITHIC_TRUE@@USE_CCM_TRUE@am__append_66 = plugins/ccm/libstrongswan-ccm.la
-@USE_GCM_TRUE@am__append_67 = plugins/gcm
-@MONOLITHIC_TRUE@@USE_GCM_TRUE@am__append_68 = plugins/gcm/libstrongswan-gcm.la
-@USE_TEST_VECTORS_TRUE@am__append_69 = plugins/test_vectors
-@MONOLITHIC_TRUE@@USE_TEST_VECTORS_TRUE@am__append_70 = plugins/test_vectors/libstrongswan-test-vectors.la
+@USE_AF_ALG_TRUE@am__append_7 = plugins/af_alg
+@MONOLITHIC_TRUE@@USE_AF_ALG_TRUE@am__append_8 = plugins/af_alg/libstrongswan-af-alg.la
+@USE_AES_TRUE@am__append_9 = plugins/aes
+@MONOLITHIC_TRUE@@USE_AES_TRUE@am__append_10 = plugins/aes/libstrongswan-aes.la
+@USE_DES_TRUE@am__append_11 = plugins/des
+@MONOLITHIC_TRUE@@USE_DES_TRUE@am__append_12 = plugins/des/libstrongswan-des.la
+@USE_BLOWFISH_TRUE@am__append_13 = plugins/blowfish
+@MONOLITHIC_TRUE@@USE_BLOWFISH_TRUE@am__append_14 = plugins/blowfish/libstrongswan-blowfish.la
+@USE_MD4_TRUE@am__append_15 = plugins/md4
+@MONOLITHIC_TRUE@@USE_MD4_TRUE@am__append_16 = plugins/md4/libstrongswan-md4.la
+@USE_MD5_TRUE@am__append_17 = plugins/md5
+@MONOLITHIC_TRUE@@USE_MD5_TRUE@am__append_18 = plugins/md5/libstrongswan-md5.la
+@USE_SHA1_TRUE@am__append_19 = plugins/sha1
+@MONOLITHIC_TRUE@@USE_SHA1_TRUE@am__append_20 = plugins/sha1/libstrongswan-sha1.la
+@USE_SHA2_TRUE@am__append_21 = plugins/sha2
+@MONOLITHIC_TRUE@@USE_SHA2_TRUE@am__append_22 = plugins/sha2/libstrongswan-sha2.la
+@USE_GMP_TRUE@am__append_23 = plugins/gmp
+@MONOLITHIC_TRUE@@USE_GMP_TRUE@am__append_24 = plugins/gmp/libstrongswan-gmp.la
+@USE_RANDOM_TRUE@am__append_25 = plugins/random
+@MONOLITHIC_TRUE@@USE_RANDOM_TRUE@am__append_26 = plugins/random/libstrongswan-random.la
+@USE_HMAC_TRUE@am__append_27 = plugins/hmac
+@MONOLITHIC_TRUE@@USE_HMAC_TRUE@am__append_28 = plugins/hmac/libstrongswan-hmac.la
+@USE_XCBC_TRUE@am__append_29 = plugins/xcbc
+@MONOLITHIC_TRUE@@USE_XCBC_TRUE@am__append_30 = plugins/xcbc/libstrongswan-xcbc.la
+@USE_X509_TRUE@am__append_31 = plugins/x509
+@MONOLITHIC_TRUE@@USE_X509_TRUE@am__append_32 = plugins/x509/libstrongswan-x509.la
+@USE_REVOCATION_TRUE@am__append_33 = plugins/revocation
+@MONOLITHIC_TRUE@@USE_REVOCATION_TRUE@am__append_34 = plugins/revocation/libstrongswan-revocation.la
+@USE_CONSTRAINTS_TRUE@am__append_35 = plugins/constraints
+@MONOLITHIC_TRUE@@USE_CONSTRAINTS_TRUE@am__append_36 = plugins/constraints/libstrongswan-constraints.la
+@USE_PUBKEY_TRUE@am__append_37 = plugins/pubkey
+@MONOLITHIC_TRUE@@USE_PUBKEY_TRUE@am__append_38 = plugins/pubkey/libstrongswan-pubkey.la
+@USE_PKCS1_TRUE@am__append_39 = plugins/pkcs1
+@MONOLITHIC_TRUE@@USE_PKCS1_TRUE@am__append_40 = plugins/pkcs1/libstrongswan-pkcs1.la
+@USE_PGP_TRUE@am__append_41 = plugins/pgp
+@MONOLITHIC_TRUE@@USE_PGP_TRUE@am__append_42 = plugins/pgp/libstrongswan-pgp.la
+@USE_DNSKEY_TRUE@am__append_43 = plugins/dnskey
+@MONOLITHIC_TRUE@@USE_DNSKEY_TRUE@am__append_44 = plugins/dnskey/libstrongswan-dnskey.la
+@USE_PEM_TRUE@am__append_45 = plugins/pem
+@MONOLITHIC_TRUE@@USE_PEM_TRUE@am__append_46 = plugins/pem/libstrongswan-pem.la
+@USE_CURL_TRUE@am__append_47 = plugins/curl
+@MONOLITHIC_TRUE@@USE_CURL_TRUE@am__append_48 = plugins/curl/libstrongswan-curl.la
+@USE_SOUP_TRUE@am__append_49 = plugins/soup
+@MONOLITHIC_TRUE@@USE_SOUP_TRUE@am__append_50 = plugins/soup/libstrongswan-soup.la
+@USE_LDAP_TRUE@am__append_51 = plugins/ldap
+@MONOLITHIC_TRUE@@USE_LDAP_TRUE@am__append_52 = plugins/ldap/libstrongswan-ldap.la
+@USE_MYSQL_TRUE@am__append_53 = plugins/mysql
+@MONOLITHIC_TRUE@@USE_MYSQL_TRUE@am__append_54 = plugins/mysql/libstrongswan-mysql.la
+@USE_SQLITE_TRUE@am__append_55 = plugins/sqlite
+@MONOLITHIC_TRUE@@USE_SQLITE_TRUE@am__append_56 = plugins/sqlite/libstrongswan-sqlite.la
+@USE_PADLOCK_TRUE@am__append_57 = plugins/padlock
+@MONOLITHIC_TRUE@@USE_PADLOCK_TRUE@am__append_58 = plugins/padlock/libstrongswan-padlock.la
+@USE_OPENSSL_TRUE@am__append_59 = plugins/openssl
+@MONOLITHIC_TRUE@@USE_OPENSSL_TRUE@am__append_60 = plugins/openssl/libstrongswan-openssl.la
+@USE_GCRYPT_TRUE@am__append_61 = plugins/gcrypt
+@MONOLITHIC_TRUE@@USE_GCRYPT_TRUE@am__append_62 = plugins/gcrypt/libstrongswan-gcrypt.la
+@USE_FIPS_PRF_TRUE@am__append_63 = plugins/fips_prf
+@MONOLITHIC_TRUE@@USE_FIPS_PRF_TRUE@am__append_64 = plugins/fips_prf/libstrongswan-fips-prf.la
+@USE_AGENT_TRUE@am__append_65 = plugins/agent
+@MONOLITHIC_TRUE@@USE_AGENT_TRUE@am__append_66 = plugins/agent/libstrongswan-agent.la
+@USE_PKCS11_TRUE@am__append_67 = plugins/pkcs11
+@MONOLITHIC_TRUE@@USE_PKCS11_TRUE@am__append_68 = plugins/pkcs11/libstrongswan-pkcs11.la
+@USE_CTR_TRUE@am__append_69 = plugins/ctr
+@MONOLITHIC_TRUE@@USE_CTR_TRUE@am__append_70 = plugins/ctr/libstrongswan-ctr.la
+@USE_CCM_TRUE@am__append_71 = plugins/ccm
+@MONOLITHIC_TRUE@@USE_CCM_TRUE@am__append_72 = plugins/ccm/libstrongswan-ccm.la
+@USE_GCM_TRUE@am__append_73 = plugins/gcm
+@MONOLITHIC_TRUE@@USE_GCM_TRUE@am__append_74 = plugins/gcm/libstrongswan-gcm.la
+@USE_TEST_VECTORS_TRUE@am__append_75 = plugins/test_vectors
+@MONOLITHIC_TRUE@@USE_TEST_VECTORS_TRUE@am__append_76 = plugins/test_vectors/libstrongswan-test-vectors.la
subdir = src/libstrongswan
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -162,7 +168,8 @@ libstrongswan_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
$(am__append_48) $(am__append_50) $(am__append_52) \
$(am__append_54) $(am__append_56) $(am__append_58) \
$(am__append_60) $(am__append_62) $(am__append_64) \
- $(am__append_66) $(am__append_68) $(am__append_70)
+ $(am__append_66) $(am__append_68) $(am__append_70) \
+ $(am__append_72) $(am__append_74) $(am__append_76)
am__libstrongswan_la_SOURCES_DIST = library.c library.h chunk.c \
chunk.h debug.c debug.h enum.c enum.h settings.h settings.c \
printf_hook.c printf_hook.h asn1/asn1.c asn1/asn1.h \
@@ -187,8 +194,7 @@ am__libstrongswan_la_SOURCES_DIST = library.c library.h chunk.c \
credentials/keys/shared_key.h \
credentials/certificates/certificate.c \
credentials/certificates/certificate.h \
- credentials/certificates/x509.h \
- credentials/certificates/x509.c credentials/certificates/ac.h \
+ credentials/certificates/x509.h credentials/certificates/ac.h \
credentials/certificates/crl.h credentials/certificates/crl.c \
credentials/certificates/pkcs10.h \
credentials/certificates/ocsp_request.h \
@@ -238,7 +244,7 @@ am_libstrongswan_la_OBJECTS = library.lo chunk.lo debug.lo enum.lo \
crypto_tester.lo diffie_hellman.lo aead.lo transform.lo \
credential_factory.lo builder.lo cred_encoding.lo \
private_key.lo public_key.lo shared_key.lo certificate.lo \
- x509.lo crl.lo ocsp_response.lo ietf_attributes.lo \
+ crl.lo ocsp_response.lo ietf_attributes.lo \
credential_manager.lo auth_cfg_wrapper.lo \
ocsp_response_wrapper.lo cert_cache.lo mem_cred.lo \
callback_cred.lo auth_cfg.lo database_factory.lo \
@@ -278,14 +284,16 @@ AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
distdir
ETAGS = etags
CTAGS = ctags
-DIST_SUBDIRS = . plugins/aes plugins/des plugins/blowfish plugins/md4 \
- plugins/md5 plugins/sha1 plugins/sha2 plugins/gmp \
- plugins/random plugins/hmac plugins/xcbc plugins/x509 \
- plugins/revocation plugins/pubkey plugins/pkcs1 plugins/pgp \
- plugins/dnskey plugins/pem plugins/curl plugins/ldap \
- plugins/mysql plugins/sqlite plugins/padlock plugins/openssl \
- plugins/gcrypt plugins/fips_prf plugins/agent plugins/pkcs11 \
- plugins/ctr plugins/ccm plugins/gcm plugins/test_vectors
+DIST_SUBDIRS = . plugins/af_alg plugins/aes plugins/des \
+ plugins/blowfish plugins/md4 plugins/md5 plugins/sha1 \
+ plugins/sha2 plugins/gmp plugins/random plugins/hmac \
+ plugins/xcbc plugins/x509 plugins/revocation \
+ plugins/constraints plugins/pubkey plugins/pkcs1 plugins/pgp \
+ plugins/dnskey plugins/pem plugins/curl plugins/soup \
+ plugins/ldap plugins/mysql plugins/sqlite plugins/padlock \
+ plugins/openssl plugins/gcrypt plugins/fips_prf plugins/agent \
+ plugins/pkcs11 plugins/ctr plugins/ccm plugins/gcm \
+ plugins/test_vectors
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
am__relativize = \
dir0=`pwd`; \
@@ -431,9 +439,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -472,6 +478,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
@@ -507,8 +515,7 @@ libstrongswan_la_SOURCES = library.c library.h chunk.c chunk.h debug.c \
credentials/keys/shared_key.h \
credentials/certificates/certificate.c \
credentials/certificates/certificate.h \
- credentials/certificates/x509.h \
- credentials/certificates/x509.c credentials/certificates/ac.h \
+ credentials/certificates/x509.h credentials/certificates/ac.h \
credentials/certificates/crl.h credentials/certificates/crl.c \
credentials/certificates/pkcs10.h \
credentials/certificates/ocsp_request.h \
@@ -559,7 +566,8 @@ libstrongswan_la_LIBADD = $(PTHREADLIB) $(DLLIB) $(BTLIB) $(SOCKLIB) \
$(am__append_48) $(am__append_50) $(am__append_52) \
$(am__append_54) $(am__append_56) $(am__append_58) \
$(am__append_60) $(am__append_62) $(am__append_64) \
- $(am__append_66) $(am__append_68) $(am__append_70)
+ $(am__append_66) $(am__append_68) $(am__append_70) \
+ $(am__append_72) $(am__append_74) $(am__append_76)
INCLUDES = -I$(top_srcdir)/src/libstrongswan
AM_CFLAGS = -DIPSEC_DIR=\"${ipsecdir}\" -DPLUGINDIR=\"${plugindir}\" \
-DSTRONGSWAN_CONF=\"${strongswan_conf}\" $(am__append_1) \
@@ -592,7 +600,9 @@ $(srcdir)/crypto/proposal/proposal_keywords.c
@MONOLITHIC_FALSE@ $(am__append_55) $(am__append_57) \
@MONOLITHIC_FALSE@ $(am__append_59) $(am__append_61) \
@MONOLITHIC_FALSE@ $(am__append_63) $(am__append_65) \
-@MONOLITHIC_FALSE@ $(am__append_67) $(am__append_69)
+@MONOLITHIC_FALSE@ $(am__append_67) $(am__append_69) \
+@MONOLITHIC_FALSE@ $(am__append_71) $(am__append_73) \
+@MONOLITHIC_FALSE@ $(am__append_75)
# build plugins with their own Makefile
#######################################
@@ -611,7 +621,9 @@ $(srcdir)/crypto/proposal/proposal_keywords.c
@MONOLITHIC_TRUE@ $(am__append_55) $(am__append_57) \
@MONOLITHIC_TRUE@ $(am__append_59) $(am__append_61) \
@MONOLITHIC_TRUE@ $(am__append_63) $(am__append_65) \
-@MONOLITHIC_TRUE@ $(am__append_67) $(am__append_69)
+@MONOLITHIC_TRUE@ $(am__append_67) $(am__append_69) \
+@MONOLITHIC_TRUE@ $(am__append_71) $(am__append_73) \
+@MONOLITHIC_TRUE@ $(am__append_75)
all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-recursive
@@ -749,7 +761,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/traffic_selector.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/transform.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x509.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -933,13 +944,6 @@ certificate.lo: credentials/certificates/certificate.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o certificate.lo `test -f 'credentials/certificates/certificate.c' || echo '$(srcdir)/'`credentials/certificates/certificate.c
-x509.lo: credentials/certificates/x509.c
-@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT x509.lo -MD -MP -MF $(DEPDIR)/x509.Tpo -c -o x509.lo `test -f 'credentials/certificates/x509.c' || echo '$(srcdir)/'`credentials/certificates/x509.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/x509.Tpo $(DEPDIR)/x509.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='credentials/certificates/x509.c' object='x509.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o x509.lo `test -f 'credentials/certificates/x509.c' || echo '$(srcdir)/'`credentials/certificates/x509.c
-
crl.lo: credentials/certificates/crl.c
@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT crl.lo -MD -MP -MF $(DEPDIR)/crl.Tpo -c -o crl.lo `test -f 'credentials/certificates/crl.c' || echo '$(srcdir)/'`credentials/certificates/crl.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/crl.Tpo $(DEPDIR)/crl.Plo
diff --git a/src/libstrongswan/asn1/asn1.c b/src/libstrongswan/asn1/asn1.c
index 6f549d42d..f80c2b93b 100644
--- a/src/libstrongswan/asn1/asn1.c
+++ b/src/libstrongswan/asn1/asn1.c
@@ -126,6 +126,100 @@ chunk_t asn1_build_known_oid(int n)
/*
* Defined in header.
*/
+chunk_t asn1_oid_from_string(char *str)
+{
+ enumerator_t *enumerator;
+ u_char buf[32];
+ char *end;
+ int i = 0, pos = 0;
+ u_int val, first = 0;
+
+ enumerator = enumerator_create_token(str, ".", "");
+ while (enumerator->enumerate(enumerator, &str))
+ {
+ val = strtoul(str, &end, 10);
+ if (end == str || pos > countof(buf))
+ {
+ pos = 0;
+ break;
+ }
+ switch (i++)
+ {
+ case 0:
+ first = val;
+ break;
+ case 1:
+ buf[pos++] = first * 40 + val;
+ break;
+ default:
+ if (val < 128)
+ {
+ buf[pos++] = val;
+ }
+ else
+ {
+ buf[pos++] = 128 | (val >> 7);
+ buf[pos++] = (val % 256) & 0x7F;
+ }
+ break;
+ }
+ }
+ enumerator->destroy(enumerator);
+
+ return chunk_clone(chunk_create(buf, pos));
+}
+
+/*
+ * Defined in header.
+ */
+char *asn1_oid_to_string(chunk_t oid)
+{
+ char buf[64], *pos = buf;
+ int len;
+ u_int val;
+
+ if (!oid.len)
+ {
+ return NULL;
+ }
+ val = oid.ptr[0] / 40;
+ len = snprintf(buf, sizeof(buf), "%d.%d", val, oid.ptr[0] - val * 40);
+ oid = chunk_skip(oid, 1);
+ if (len < 0 || len >= sizeof(buf))
+ {
+ return NULL;
+ }
+ pos += len;
+
+ while (oid.len)
+ {
+ if (oid.ptr[0] < 128)
+ {
+ len = snprintf(pos, sizeof(buf) + buf - pos, ".%d", oid.ptr[0]);
+ oid = chunk_skip(oid, 1);
+ }
+ else
+ {
+ if (oid.len == 1)
+ {
+ return NULL;
+ }
+ val = ((u_int)(oid.ptr[0] & 0x7F) << 7) + oid.ptr[1];
+ len = snprintf(pos, sizeof(buf) + buf - pos, ".%d", val);
+ oid = chunk_skip(oid, 2);
+ }
+ if (len < 0 || len >= sizeof(buf) + buf - pos)
+ {
+ return NULL;
+ }
+ pos += len;
+ }
+ return strdup(buf);
+}
+
+/*
+ * Defined in header.
+ */
size_t asn1_length(chunk_t *blob)
{
u_char n;
diff --git a/src/libstrongswan/asn1/asn1.h b/src/libstrongswan/asn1/asn1.h
index 866c28095..05a060827 100644
--- a/src/libstrongswan/asn1/asn1.h
+++ b/src/libstrongswan/asn1/asn1.h
@@ -115,6 +115,22 @@ int asn1_known_oid(chunk_t object);
chunk_t asn1_build_known_oid(int n);
/**
+ * Convert human readable OID to ASN.1 DER encoding, without OID header.
+ *
+ * @param str OID string (e.g. 1.2.345.67.8)
+ * @return allocated ASN.1 encoded OID, chunk_empty on error
+ */
+chunk_t asn1_oid_from_string(char *str);
+
+/**
+ * Convert a DER encoded ASN.1 OID to a human readable string.
+ *
+ * @param oid DER encoded OID, without header
+ * @return human readable OID string, allocated, NULL on error
+ */
+char* asn1_oid_to_string(chunk_t oid);
+
+/**
* Returns the length of an ASN.1 object
* The blob pointer is advanced past the tag length fields
*
diff --git a/src/libstrongswan/asn1/asn1_parser.c b/src/libstrongswan/asn1/asn1_parser.c
index 3e5bbbabd..2a7a38a52 100644
--- a/src/libstrongswan/asn1/asn1_parser.c
+++ b/src/libstrongswan/asn1/asn1_parser.c
@@ -78,10 +78,8 @@ struct private_asn1_parser_t {
chunk_t blobs[ASN1_MAX_LEVEL + 2];
};
-/**
- * Implementation of asn1_parser_t.iterate
- */
-static bool iterate(private_asn1_parser_t *this, int *objectID, chunk_t *object)
+METHOD(asn1_parser_t, iterate, bool,
+ private_asn1_parser_t *this, int *objectID, chunk_t *object)
{
chunk_t *blob, *blob1;
u_char *start_ptr;
@@ -234,43 +232,33 @@ end:
return this->success;
}
-/**
- * Implementation of asn1_parser_t.get_level
- */
-static u_int get_level(private_asn1_parser_t *this)
+METHOD(asn1_parser_t, get_level, u_int,
+private_asn1_parser_t *this)
{
return this->level0 + this->objects[this->line].level;
}
-/**
- * Implementation of asn1_parser_t.set_top_level
- */
-static void set_top_level(private_asn1_parser_t *this, u_int level0)
+METHOD(asn1_parser_t, set_top_level, void,
+ private_asn1_parser_t *this, u_int level0)
{
this->level0 = level0;
}
-/**
- * Implementation of asn1_parser_t.set_flags
- */
-static void set_flags(private_asn1_parser_t *this, bool implicit, bool private)
+METHOD(asn1_parser_t, set_flags, void,
+ private_asn1_parser_t *this, bool implicit, bool private)
{
this->implicit = implicit;
this->private = private;
}
-/**
- * Implementation of asn1_parser_t.success
- */
-static bool success(private_asn1_parser_t *this)
+METHOD(asn1_parser_t, success, bool,
+ private_asn1_parser_t *this)
{
return this->success;
}
-/**
- * Implementation of asn1_parser_t.destroy
- */
-static void destroy(private_asn1_parser_t *this)
+METHOD(asn1_parser_t, destroy, void,
+ private_asn1_parser_t *this)
{
free(this);
}
@@ -280,20 +268,22 @@ static void destroy(private_asn1_parser_t *this)
*/
asn1_parser_t* asn1_parser_create(asn1Object_t const *objects, chunk_t blob)
{
- private_asn1_parser_t *this = malloc_thing(private_asn1_parser_t);
-
- memset(this, '\0', sizeof(private_asn1_parser_t));
- this->objects = objects;
- this->blobs[0] = blob;
- this->line = -1;
- this->success = TRUE;
-
- this->public.iterate = (bool (*)(asn1_parser_t*, int*, chunk_t*))iterate;
- this->public.get_level = (u_int (*)(asn1_parser_t*))get_level;
- this->public.set_top_level = (void (*)(asn1_parser_t*, u_int))set_top_level;
- this->public.set_flags = (void (*)(asn1_parser_t*, bool, bool))set_flags;
- this->public.success = (bool (*)(asn1_parser_t*))success;
- this->public.destroy = (void (*)(asn1_parser_t*))destroy;
+ private_asn1_parser_t *this;
+
+ INIT(this,
+ .public = {
+ .iterate = _iterate,
+ .get_level = _get_level,
+ .set_top_level = _set_top_level,
+ .set_flags = _set_flags,
+ .success = _success,
+ .destroy = _destroy,
+ },
+ .objects = objects,
+ .blobs[0] = blob,
+ .line = -1,
+ .success = TRUE,
+ );
return &this->public;
}
diff --git a/src/libstrongswan/asn1/oid.c b/src/libstrongswan/asn1/oid.c
index 1e5dec8a5..57a00a39e 100644
--- a/src/libstrongswan/asn1/oid.c
+++ b/src/libstrongswan/asn1/oid.c
@@ -10,360 +10,363 @@
#include "oid.h"
const oid_t oid_names[] = {
- {0x02, 7, 1, 0, "ITU-T Administration" }, /* 0 */
- { 0x82, 0, 1, 1, "" }, /* 1 */
- { 0x06, 0, 1, 2, "Germany ITU-T member" }, /* 2 */
- { 0x01, 0, 1, 3, "Deutsche Telekom AG" }, /* 3 */
- { 0x0A, 0, 1, 4, "" }, /* 4 */
- { 0x07, 0, 1, 5, "" }, /* 5 */
- { 0x14, 0, 0, 6, "ND" }, /* 6 */
- {0x09, 18, 1, 0, "data" }, /* 7 */
- { 0x92, 0, 1, 1, "" }, /* 8 */
- { 0x26, 0, 1, 2, "" }, /* 9 */
- { 0x89, 0, 1, 3, "" }, /* 10 */
- { 0x93, 0, 1, 4, "" }, /* 11 */
- { 0xF2, 0, 1, 5, "" }, /* 12 */
- { 0x2C, 0, 1, 6, "" }, /* 13 */
- { 0x64, 0, 1, 7, "pilot" }, /* 14 */
- { 0x01, 0, 1, 8, "pilotAttributeType" }, /* 15 */
- { 0x01, 17, 0, 9, "UID" }, /* 16 */
- { 0x19, 0, 0, 9, "DC" }, /* 17 */
- {0x55, 64, 1, 0, "X.500" }, /* 18 */
- { 0x04, 36, 1, 1, "X.509" }, /* 19 */
- { 0x03, 21, 0, 2, "CN" }, /* 20 */
- { 0x04, 22, 0, 2, "S" }, /* 21 */
- { 0x05, 23, 0, 2, "SN" }, /* 22 */
- { 0x06, 24, 0, 2, "C" }, /* 23 */
- { 0x07, 25, 0, 2, "L" }, /* 24 */
- { 0x08, 26, 0, 2, "ST" }, /* 25 */
- { 0x0A, 27, 0, 2, "O" }, /* 26 */
- { 0x0B, 28, 0, 2, "OU" }, /* 27 */
- { 0x0C, 29, 0, 2, "T" }, /* 28 */
- { 0x0D, 30, 0, 2, "D" }, /* 29 */
- { 0x24, 31, 0, 2, "userCertificate" }, /* 30 */
- { 0x29, 32, 0, 2, "N" }, /* 31 */
- { 0x2A, 33, 0, 2, "G" }, /* 32 */
- { 0x2B, 34, 0, 2, "I" }, /* 33 */
- { 0x2D, 35, 0, 2, "ID" }, /* 34 */
- { 0x48, 0, 0, 2, "role" }, /* 35 */
- { 0x1D, 0, 1, 1, "id-ce" }, /* 36 */
- { 0x09, 38, 0, 2, "subjectDirectoryAttrs" }, /* 37 */
- { 0x0E, 39, 0, 2, "subjectKeyIdentifier" }, /* 38 */
- { 0x0F, 40, 0, 2, "keyUsage" }, /* 39 */
- { 0x10, 41, 0, 2, "privateKeyUsagePeriod" }, /* 40 */
- { 0x11, 42, 0, 2, "subjectAltName" }, /* 41 */
- { 0x12, 43, 0, 2, "issuerAltName" }, /* 42 */
- { 0x13, 44, 0, 2, "basicConstraints" }, /* 43 */
- { 0x14, 45, 0, 2, "crlNumber" }, /* 44 */
- { 0x15, 46, 0, 2, "reasonCode" }, /* 45 */
- { 0x17, 47, 0, 2, "holdInstructionCode" }, /* 46 */
- { 0x18, 48, 0, 2, "invalidityDate" }, /* 47 */
- { 0x1B, 49, 0, 2, "deltaCrlIndicator" }, /* 48 */
- { 0x1C, 50, 0, 2, "issuingDistributionPoint" }, /* 49 */
- { 0x1D, 51, 0, 2, "certificateIssuer" }, /* 50 */
- { 0x1E, 52, 0, 2, "nameConstraints" }, /* 51 */
- { 0x1F, 53, 0, 2, "crlDistributionPoints" }, /* 52 */
- { 0x20, 55, 1, 2, "certificatePolicies" }, /* 53 */
- { 0x00, 0, 0, 3, "anyPolicy" }, /* 54 */
- { 0x21, 56, 0, 2, "policyMappings" }, /* 55 */
- { 0x23, 57, 0, 2, "authorityKeyIdentifier" }, /* 56 */
- { 0x24, 58, 0, 2, "policyConstraints" }, /* 57 */
- { 0x25, 60, 1, 2, "extendedKeyUsage" }, /* 58 */
- { 0x00, 0, 0, 3, "anyExtendedKeyUsage" }, /* 59 */
- { 0x2E, 61, 0, 2, "freshestCRL" }, /* 60 */
- { 0x36, 62, 0, 2, "inhibitAnyPolicy" }, /* 61 */
- { 0x37, 63, 0, 2, "targetInformation" }, /* 62 */
- { 0x38, 0, 0, 2, "noRevAvail" }, /* 63 */
- {0x2A, 161, 1, 0, "" }, /* 64 */
- { 0x83, 77, 1, 1, "" }, /* 65 */
- { 0x08, 0, 1, 2, "jp" }, /* 66 */
- { 0x8C, 0, 1, 3, "" }, /* 67 */
- { 0x9A, 0, 1, 4, "" }, /* 68 */
- { 0x4B, 0, 1, 5, "" }, /* 69 */
- { 0x3D, 0, 1, 6, "" }, /* 70 */
- { 0x01, 0, 1, 7, "security" }, /* 71 */
- { 0x01, 0, 1, 8, "algorithm" }, /* 72 */
- { 0x01, 0, 1, 9, "symm-encryption-alg" }, /* 73 */
- { 0x02, 75, 0, 10, "camellia128-cbc" }, /* 74 */
- { 0x03, 76, 0, 10, "camellia192-cbc" }, /* 75 */
- { 0x04, 0, 0, 10, "camellia256-cbc" }, /* 76 */
- { 0x86, 0, 1, 1, "" }, /* 77 */
- { 0x48, 0, 1, 2, "us" }, /* 78 */
- { 0x86, 120, 1, 3, "" }, /* 79 */
- { 0xF6, 85, 1, 4, "" }, /* 80 */
- { 0x7D, 0, 1, 5, "NortelNetworks" }, /* 81 */
- { 0x07, 0, 1, 6, "Entrust" }, /* 82 */
- { 0x41, 0, 1, 7, "nsn-ce" }, /* 83 */
- { 0x00, 0, 0, 8, "entrustVersInfo" }, /* 84 */
- { 0xF7, 0, 1, 4, "" }, /* 85 */
- { 0x0D, 0, 1, 5, "RSADSI" }, /* 86 */
- { 0x01, 115, 1, 6, "PKCS" }, /* 87 */
- { 0x01, 97, 1, 7, "PKCS-1" }, /* 88 */
- { 0x01, 90, 0, 8, "rsaEncryption" }, /* 89 */
- { 0x02, 91, 0, 8, "md2WithRSAEncryption" }, /* 90 */
- { 0x04, 92, 0, 8, "md5WithRSAEncryption" }, /* 91 */
- { 0x05, 93, 0, 8, "sha-1WithRSAEncryption" }, /* 92 */
- { 0x0B, 94, 0, 8, "sha256WithRSAEncryption" }, /* 93 */
- { 0x0C, 95, 0, 8, "sha384WithRSAEncryption" }, /* 94 */
- { 0x0D, 96, 0, 8, "sha512WithRSAEncryption" }, /* 95 */
- { 0x0E, 0, 0, 8, "sha224WithRSAEncryption" }, /* 96 */
- { 0x07, 104, 1, 7, "PKCS-7" }, /* 97 */
- { 0x01, 99, 0, 8, "data" }, /* 98 */
- { 0x02, 100, 0, 8, "signedData" }, /* 99 */
- { 0x03, 101, 0, 8, "envelopedData" }, /* 100 */
- { 0x04, 102, 0, 8, "signedAndEnvelopedData" }, /* 101 */
- { 0x05, 103, 0, 8, "digestedData" }, /* 102 */
- { 0x06, 0, 0, 8, "encryptedData" }, /* 103 */
- { 0x09, 0, 1, 7, "PKCS-9" }, /* 104 */
- { 0x01, 106, 0, 8, "E" }, /* 105 */
- { 0x02, 107, 0, 8, "unstructuredName" }, /* 106 */
- { 0x03, 108, 0, 8, "contentType" }, /* 107 */
- { 0x04, 109, 0, 8, "messageDigest" }, /* 108 */
- { 0x05, 110, 0, 8, "signingTime" }, /* 109 */
- { 0x06, 111, 0, 8, "counterSignature" }, /* 110 */
- { 0x07, 112, 0, 8, "challengePassword" }, /* 111 */
- { 0x08, 113, 0, 8, "unstructuredAddress" }, /* 112 */
- { 0x0E, 114, 0, 8, "extensionRequest" }, /* 113 */
- { 0x0F, 0, 0, 8, "S/MIME Capabilities" }, /* 114 */
- { 0x02, 118, 1, 6, "digestAlgorithm" }, /* 115 */
- { 0x02, 117, 0, 7, "md2" }, /* 116 */
- { 0x05, 0, 0, 7, "md5" }, /* 117 */
- { 0x03, 0, 1, 6, "encryptionAlgorithm" }, /* 118 */
- { 0x07, 0, 0, 7, "3des-ede-cbc" }, /* 119 */
- { 0xCE, 0, 1, 3, "" }, /* 120 */
- { 0x3D, 0, 1, 4, "ansi-X9-62" }, /* 121 */
- { 0x02, 124, 1, 5, "id-publicKeyType" }, /* 122 */
- { 0x01, 0, 0, 6, "id-ecPublicKey" }, /* 123 */
- { 0x03, 154, 1, 5, "ellipticCurve" }, /* 124 */
- { 0x00, 146, 1, 6, "c-TwoCurve" }, /* 125 */
- { 0x01, 127, 0, 7, "c2pnb163v1" }, /* 126 */
- { 0x02, 128, 0, 7, "c2pnb163v2" }, /* 127 */
- { 0x03, 129, 0, 7, "c2pnb163v3" }, /* 128 */
- { 0x04, 130, 0, 7, "c2pnb176w1" }, /* 129 */
- { 0x05, 131, 0, 7, "c2tnb191v1" }, /* 130 */
- { 0x06, 132, 0, 7, "c2tnb191v2" }, /* 131 */
- { 0x07, 133, 0, 7, "c2tnb191v3" }, /* 132 */
- { 0x08, 134, 0, 7, "c2onb191v4" }, /* 133 */
- { 0x09, 135, 0, 7, "c2onb191v5" }, /* 134 */
- { 0x0A, 136, 0, 7, "c2pnb208w1" }, /* 135 */
- { 0x0B, 137, 0, 7, "c2tnb239v1" }, /* 136 */
- { 0x0C, 138, 0, 7, "c2tnb239v2" }, /* 137 */
- { 0x0D, 139, 0, 7, "c2tnb239v3" }, /* 138 */
- { 0x0E, 140, 0, 7, "c2onb239v4" }, /* 139 */
- { 0x0F, 141, 0, 7, "c2onb239v5" }, /* 140 */
- { 0x10, 142, 0, 7, "c2pnb272w1" }, /* 141 */
- { 0x11, 143, 0, 7, "c2pnb304w1" }, /* 142 */
- { 0x12, 144, 0, 7, "c2tnb359v1" }, /* 143 */
- { 0x13, 145, 0, 7, "c2pnb368w1" }, /* 144 */
- { 0x14, 0, 0, 7, "c2tnb431r1" }, /* 145 */
- { 0x01, 0, 1, 6, "primeCurve" }, /* 146 */
- { 0x01, 148, 0, 7, "prime192v1" }, /* 147 */
- { 0x02, 149, 0, 7, "prime192v2" }, /* 148 */
- { 0x03, 150, 0, 7, "prime192v3" }, /* 149 */
- { 0x04, 151, 0, 7, "prime239v1" }, /* 150 */
- { 0x05, 152, 0, 7, "prime239v2" }, /* 151 */
- { 0x06, 153, 0, 7, "prime239v3" }, /* 152 */
- { 0x07, 0, 0, 7, "prime256v1" }, /* 153 */
- { 0x04, 0, 1, 5, "id-ecSigType" }, /* 154 */
- { 0x01, 156, 0, 6, "ecdsa-with-SHA1" }, /* 155 */
- { 0x03, 0, 1, 6, "ecdsa-with-Specified" }, /* 156 */
- { 0x01, 158, 0, 7, "ecdsa-with-SHA224" }, /* 157 */
- { 0x02, 159, 0, 7, "ecdsa-with-SHA256" }, /* 158 */
- { 0x03, 160, 0, 7, "ecdsa-with-SHA384" }, /* 159 */
- { 0x04, 0, 0, 7, "ecdsa-with-SHA512" }, /* 160 */
- {0x2B, 309, 1, 0, "" }, /* 161 */
- { 0x06, 223, 1, 1, "dod" }, /* 162 */
- { 0x01, 0, 1, 2, "internet" }, /* 163 */
- { 0x04, 183, 1, 3, "private" }, /* 164 */
- { 0x01, 0, 1, 4, "enterprise" }, /* 165 */
- { 0x82, 176, 1, 5, "" }, /* 166 */
- { 0x37, 0, 1, 6, "Microsoft" }, /* 167 */
- { 0x0A, 172, 1, 7, "" }, /* 168 */
- { 0x03, 0, 1, 8, "" }, /* 169 */
- { 0x03, 171, 0, 9, "msSGC" }, /* 170 */
- { 0x04, 0, 0, 9, "msEncryptingFileSystem" }, /* 171 */
- { 0x14, 0, 1, 7, "msEnrollmentInfrastructure"}, /* 172 */
- { 0x02, 0, 1, 8, "msCertificateTypeExtension"}, /* 173 */
- { 0x02, 175, 0, 9, "msSmartcardLogon" }, /* 174 */
- { 0x03, 0, 0, 9, "msUPN" }, /* 175 */
- { 0x89, 0, 1, 5, "" }, /* 176 */
- { 0x31, 0, 1, 6, "" }, /* 177 */
- { 0x01, 0, 1, 7, "" }, /* 178 */
- { 0x01, 0, 1, 8, "" }, /* 179 */
- { 0x02, 0, 1, 9, "" }, /* 180 */
- { 0x02, 182, 0, 10, "" }, /* 181 */
- { 0x4B, 0, 0, 10, "TCGID" }, /* 182 */
- { 0x05, 0, 1, 3, "security" }, /* 183 */
- { 0x05, 0, 1, 4, "mechanisms" }, /* 184 */
- { 0x07, 0, 1, 5, "id-pkix" }, /* 185 */
- { 0x01, 190, 1, 6, "id-pe" }, /* 186 */
- { 0x01, 188, 0, 7, "authorityInfoAccess" }, /* 187 */
- { 0x03, 189, 0, 7, "qcStatements" }, /* 188 */
- { 0x07, 0, 0, 7, "ipAddrBlocks" }, /* 189 */
- { 0x02, 193, 1, 6, "id-qt" }, /* 190 */
- { 0x01, 192, 0, 7, "cps" }, /* 191 */
- { 0x02, 0, 0, 7, "unotice" }, /* 192 */
- { 0x03, 203, 1, 6, "id-kp" }, /* 193 */
- { 0x01, 195, 0, 7, "serverAuth" }, /* 194 */
- { 0x02, 196, 0, 7, "clientAuth" }, /* 195 */
- { 0x03, 197, 0, 7, "codeSigning" }, /* 196 */
- { 0x04, 198, 0, 7, "emailProtection" }, /* 197 */
- { 0x05, 199, 0, 7, "ipsecEndSystem" }, /* 198 */
- { 0x06, 200, 0, 7, "ipsecTunnel" }, /* 199 */
- { 0x07, 201, 0, 7, "ipsecUser" }, /* 200 */
- { 0x08, 202, 0, 7, "timeStamping" }, /* 201 */
- { 0x09, 0, 0, 7, "ocspSigning" }, /* 202 */
- { 0x08, 205, 1, 6, "id-otherNames" }, /* 203 */
- { 0x05, 0, 0, 7, "xmppAddr" }, /* 204 */
- { 0x0A, 210, 1, 6, "id-aca" }, /* 205 */
- { 0x01, 207, 0, 7, "authenticationInfo" }, /* 206 */
- { 0x02, 208, 0, 7, "accessIdentity" }, /* 207 */
- { 0x03, 209, 0, 7, "chargingIdentity" }, /* 208 */
- { 0x04, 0, 0, 7, "group" }, /* 209 */
- { 0x0B, 211, 0, 6, "subjectInfoAccess" }, /* 210 */
- { 0x30, 0, 1, 6, "id-ad" }, /* 211 */
- { 0x01, 220, 1, 7, "ocsp" }, /* 212 */
- { 0x01, 214, 0, 8, "basic" }, /* 213 */
- { 0x02, 215, 0, 8, "nonce" }, /* 214 */
- { 0x03, 216, 0, 8, "crl" }, /* 215 */
- { 0x04, 217, 0, 8, "response" }, /* 216 */
- { 0x05, 218, 0, 8, "noCheck" }, /* 217 */
- { 0x06, 219, 0, 8, "archiveCutoff" }, /* 218 */
- { 0x07, 0, 0, 8, "serviceLocator" }, /* 219 */
- { 0x02, 221, 0, 7, "caIssuers" }, /* 220 */
- { 0x03, 222, 0, 7, "timeStamping" }, /* 221 */
- { 0x05, 0, 0, 7, "caRepository" }, /* 222 */
- { 0x0E, 229, 1, 1, "oiw" }, /* 223 */
- { 0x03, 0, 1, 2, "secsig" }, /* 224 */
- { 0x02, 0, 1, 3, "algorithms" }, /* 225 */
- { 0x07, 227, 0, 4, "des-cbc" }, /* 226 */
- { 0x1A, 228, 0, 4, "sha-1" }, /* 227 */
- { 0x1D, 0, 0, 4, "sha-1WithRSASignature" }, /* 228 */
- { 0x24, 275, 1, 1, "TeleTrusT" }, /* 229 */
- { 0x03, 0, 1, 2, "algorithm" }, /* 230 */
- { 0x03, 0, 1, 3, "signatureAlgorithm" }, /* 231 */
- { 0x01, 236, 1, 4, "rsaSignature" }, /* 232 */
- { 0x02, 234, 0, 5, "rsaSigWithripemd160" }, /* 233 */
- { 0x03, 235, 0, 5, "rsaSigWithripemd128" }, /* 234 */
- { 0x04, 0, 0, 5, "rsaSigWithripemd256" }, /* 235 */
- { 0x02, 0, 1, 4, "ecSign" }, /* 236 */
- { 0x01, 238, 0, 5, "ecSignWithsha1" }, /* 237 */
- { 0x02, 239, 0, 5, "ecSignWithripemd160" }, /* 238 */
- { 0x03, 240, 0, 5, "ecSignWithmd2" }, /* 239 */
- { 0x04, 241, 0, 5, "ecSignWithmd5" }, /* 240 */
- { 0x05, 258, 1, 5, "ttt-ecg" }, /* 241 */
- { 0x01, 246, 1, 6, "fieldType" }, /* 242 */
- { 0x01, 0, 1, 7, "characteristictwoField" }, /* 243 */
- { 0x01, 0, 1, 8, "basisType" }, /* 244 */
- { 0x01, 0, 0, 9, "ipBasis" }, /* 245 */
- { 0x02, 248, 1, 6, "keyType" }, /* 246 */
- { 0x01, 0, 0, 7, "ecgPublicKey" }, /* 247 */
- { 0x03, 249, 0, 6, "curve" }, /* 248 */
- { 0x04, 256, 1, 6, "signatures" }, /* 249 */
- { 0x01, 251, 0, 7, "ecgdsa-with-RIPEMD160" }, /* 250 */
- { 0x02, 252, 0, 7, "ecgdsa-with-SHA1" }, /* 251 */
- { 0x03, 253, 0, 7, "ecgdsa-with-SHA224" }, /* 252 */
- { 0x04, 254, 0, 7, "ecgdsa-with-SHA256" }, /* 253 */
- { 0x05, 255, 0, 7, "ecgdsa-with-SHA384" }, /* 254 */
- { 0x06, 0, 0, 7, "ecgdsa-with-SHA512" }, /* 255 */
- { 0x05, 0, 1, 6, "module" }, /* 256 */
- { 0x01, 0, 0, 7, "1" }, /* 257 */
- { 0x08, 0, 1, 5, "ecStdCurvesAndGeneration" }, /* 258 */
- { 0x01, 0, 1, 6, "ellipticCurve" }, /* 259 */
- { 0x01, 0, 1, 7, "versionOne" }, /* 260 */
- { 0x01, 262, 0, 8, "brainpoolP160r1" }, /* 261 */
- { 0x02, 263, 0, 8, "brainpoolP160t1" }, /* 262 */
- { 0x03, 264, 0, 8, "brainpoolP192r1" }, /* 263 */
- { 0x04, 265, 0, 8, "brainpoolP192t1" }, /* 264 */
- { 0x05, 266, 0, 8, "brainpoolP224r1" }, /* 265 */
- { 0x06, 267, 0, 8, "brainpoolP224t1" }, /* 266 */
- { 0x07, 268, 0, 8, "brainpoolP256r1" }, /* 267 */
- { 0x08, 269, 0, 8, "brainpoolP256t1" }, /* 268 */
- { 0x09, 270, 0, 8, "brainpoolP320r1" }, /* 269 */
- { 0x0A, 271, 0, 8, "brainpoolP320t1" }, /* 270 */
- { 0x0B, 272, 0, 8, "brainpoolP384r1" }, /* 271 */
- { 0x0C, 273, 0, 8, "brainpoolP384t1" }, /* 272 */
- { 0x0D, 274, 0, 8, "brainpoolP512r1" }, /* 273 */
- { 0x0E, 0, 0, 8, "brainpoolP512t1" }, /* 274 */
- { 0x81, 0, 1, 1, "" }, /* 275 */
- { 0x04, 0, 1, 2, "Certicom" }, /* 276 */
- { 0x00, 0, 1, 3, "curve" }, /* 277 */
- { 0x01, 279, 0, 4, "sect163k1" }, /* 278 */
- { 0x02, 280, 0, 4, "sect163r1" }, /* 279 */
- { 0x03, 281, 0, 4, "sect239k1" }, /* 280 */
- { 0x04, 282, 0, 4, "sect113r1" }, /* 281 */
- { 0x05, 283, 0, 4, "sect113r2" }, /* 282 */
- { 0x06, 284, 0, 4, "secp112r1" }, /* 283 */
- { 0x07, 285, 0, 4, "secp112r2" }, /* 284 */
- { 0x08, 286, 0, 4, "secp160r1" }, /* 285 */
- { 0x09, 287, 0, 4, "secp160k1" }, /* 286 */
- { 0x0A, 288, 0, 4, "secp256k1" }, /* 287 */
- { 0x0F, 289, 0, 4, "sect163r2" }, /* 288 */
- { 0x10, 290, 0, 4, "sect283k1" }, /* 289 */
- { 0x11, 291, 0, 4, "sect283r1" }, /* 290 */
- { 0x16, 292, 0, 4, "sect131r1" }, /* 291 */
- { 0x17, 293, 0, 4, "sect131r2" }, /* 292 */
- { 0x18, 294, 0, 4, "sect193r1" }, /* 293 */
- { 0x19, 295, 0, 4, "sect193r2" }, /* 294 */
- { 0x1A, 296, 0, 4, "sect233k1" }, /* 295 */
- { 0x1B, 297, 0, 4, "sect233r1" }, /* 296 */
- { 0x1C, 298, 0, 4, "secp128r1" }, /* 297 */
- { 0x1D, 299, 0, 4, "secp128r2" }, /* 298 */
- { 0x1E, 300, 0, 4, "secp160r2" }, /* 299 */
- { 0x1F, 301, 0, 4, "secp192k1" }, /* 300 */
- { 0x20, 302, 0, 4, "secp224k1" }, /* 301 */
- { 0x21, 303, 0, 4, "secp224r1" }, /* 302 */
- { 0x22, 304, 0, 4, "secp384r1" }, /* 303 */
- { 0x23, 305, 0, 4, "secp521r1" }, /* 304 */
- { 0x24, 306, 0, 4, "sect409k1" }, /* 305 */
- { 0x25, 307, 0, 4, "sect409r1" }, /* 306 */
- { 0x26, 308, 0, 4, "sect571k1" }, /* 307 */
- { 0x27, 0, 0, 4, "sect571r1" }, /* 308 */
- {0x60, 0, 1, 0, "" }, /* 309 */
- { 0x86, 0, 1, 1, "" }, /* 310 */
- { 0x48, 0, 1, 2, "" }, /* 311 */
- { 0x01, 0, 1, 3, "organization" }, /* 312 */
- { 0x65, 331, 1, 4, "gov" }, /* 313 */
- { 0x03, 0, 1, 5, "csor" }, /* 314 */
- { 0x04, 0, 1, 6, "nistalgorithm" }, /* 315 */
- { 0x01, 326, 1, 7, "aes" }, /* 316 */
- { 0x02, 318, 0, 8, "id-aes128-CBC" }, /* 317 */
- { 0x06, 319, 0, 8, "id-aes128-GCM" }, /* 318 */
- { 0x07, 320, 0, 8, "id-aes128-CCM" }, /* 319 */
- { 0x16, 321, 0, 8, "id-aes192-CBC" }, /* 320 */
- { 0x1A, 322, 0, 8, "id-aes192-GCM" }, /* 321 */
- { 0x1B, 323, 0, 8, "id-aes192-CCM" }, /* 322 */
- { 0x2A, 324, 0, 8, "id-aes256-CBC" }, /* 323 */
- { 0x2E, 325, 0, 8, "id-aes256-GCM" }, /* 324 */
- { 0x2F, 0, 0, 8, "id-aes256-CCM" }, /* 325 */
- { 0x02, 0, 1, 7, "hashalgs" }, /* 326 */
- { 0x01, 328, 0, 8, "id-SHA-256" }, /* 327 */
- { 0x02, 329, 0, 8, "id-SHA-384" }, /* 328 */
- { 0x03, 330, 0, 8, "id-SHA-512" }, /* 329 */
- { 0x04, 0, 0, 8, "id-SHA-224" }, /* 330 */
- { 0x86, 0, 1, 4, "" }, /* 331 */
- { 0xf8, 0, 1, 5, "" }, /* 332 */
- { 0x42, 345, 1, 6, "netscape" }, /* 333 */
- { 0x01, 340, 1, 7, "" }, /* 334 */
- { 0x01, 336, 0, 8, "nsCertType" }, /* 335 */
- { 0x03, 337, 0, 8, "nsRevocationUrl" }, /* 336 */
- { 0x04, 338, 0, 8, "nsCaRevocationUrl" }, /* 337 */
- { 0x08, 339, 0, 8, "nsCaPolicyUrl" }, /* 338 */
- { 0x0d, 0, 0, 8, "nsComment" }, /* 339 */
- { 0x03, 343, 1, 7, "directory" }, /* 340 */
- { 0x01, 0, 1, 8, "" }, /* 341 */
- { 0x03, 0, 0, 9, "employeeNumber" }, /* 342 */
- { 0x04, 0, 1, 7, "policy" }, /* 343 */
- { 0x01, 0, 0, 8, "nsSGC" }, /* 344 */
- { 0x45, 0, 1, 6, "verisign" }, /* 345 */
- { 0x01, 0, 1, 7, "pki" }, /* 346 */
- { 0x09, 0, 1, 8, "attributes" }, /* 347 */
- { 0x02, 349, 0, 9, "messageType" }, /* 348 */
- { 0x03, 350, 0, 9, "pkiStatus" }, /* 349 */
- { 0x04, 351, 0, 9, "failInfo" }, /* 350 */
- { 0x05, 352, 0, 9, "senderNonce" }, /* 351 */
- { 0x06, 353, 0, 9, "recipientNonce" }, /* 352 */
- { 0x07, 354, 0, 9, "transID" }, /* 353 */
- { 0x08, 355, 0, 9, "extensionReq" }, /* 354 */
- { 0x08, 0, 0, 9, "extensionReq" } /* 355 */
+ {0x02, 7, 1, 0, "ITU-T Administration" }, /* 0 */
+ { 0x82, 0, 1, 1, "" }, /* 1 */
+ { 0x06, 0, 1, 2, "Germany ITU-T member" }, /* 2 */
+ { 0x01, 0, 1, 3, "Deutsche Telekom AG" }, /* 3 */
+ { 0x0A, 0, 1, 4, "" }, /* 4 */
+ { 0x07, 0, 1, 5, "" }, /* 5 */
+ { 0x14, 0, 0, 6, "ND" }, /* 6 */
+ {0x09, 18, 1, 0, "data" }, /* 7 */
+ { 0x92, 0, 1, 1, "" }, /* 8 */
+ { 0x26, 0, 1, 2, "" }, /* 9 */
+ { 0x89, 0, 1, 3, "" }, /* 10 */
+ { 0x93, 0, 1, 4, "" }, /* 11 */
+ { 0xF2, 0, 1, 5, "" }, /* 12 */
+ { 0x2C, 0, 1, 6, "" }, /* 13 */
+ { 0x64, 0, 1, 7, "pilot" }, /* 14 */
+ { 0x01, 0, 1, 8, "pilotAttributeType" }, /* 15 */
+ { 0x01, 17, 0, 9, "UID" }, /* 16 */
+ { 0x19, 0, 0, 9, "DC" }, /* 17 */
+ {0x55, 64, 1, 0, "X.500" }, /* 18 */
+ { 0x04, 36, 1, 1, "X.509" }, /* 19 */
+ { 0x03, 21, 0, 2, "CN" }, /* 20 */
+ { 0x04, 22, 0, 2, "S" }, /* 21 */
+ { 0x05, 23, 0, 2, "SN" }, /* 22 */
+ { 0x06, 24, 0, 2, "C" }, /* 23 */
+ { 0x07, 25, 0, 2, "L" }, /* 24 */
+ { 0x08, 26, 0, 2, "ST" }, /* 25 */
+ { 0x0A, 27, 0, 2, "O" }, /* 26 */
+ { 0x0B, 28, 0, 2, "OU" }, /* 27 */
+ { 0x0C, 29, 0, 2, "T" }, /* 28 */
+ { 0x0D, 30, 0, 2, "D" }, /* 29 */
+ { 0x24, 31, 0, 2, "userCertificate" }, /* 30 */
+ { 0x29, 32, 0, 2, "N" }, /* 31 */
+ { 0x2A, 33, 0, 2, "G" }, /* 32 */
+ { 0x2B, 34, 0, 2, "I" }, /* 33 */
+ { 0x2D, 35, 0, 2, "ID" }, /* 34 */
+ { 0x48, 0, 0, 2, "role" }, /* 35 */
+ { 0x1D, 0, 1, 1, "id-ce" }, /* 36 */
+ { 0x09, 38, 0, 2, "subjectDirectoryAttrs" }, /* 37 */
+ { 0x0E, 39, 0, 2, "subjectKeyIdentifier" }, /* 38 */
+ { 0x0F, 40, 0, 2, "keyUsage" }, /* 39 */
+ { 0x10, 41, 0, 2, "privateKeyUsagePeriod" }, /* 40 */
+ { 0x11, 42, 0, 2, "subjectAltName" }, /* 41 */
+ { 0x12, 43, 0, 2, "issuerAltName" }, /* 42 */
+ { 0x13, 44, 0, 2, "basicConstraints" }, /* 43 */
+ { 0x14, 45, 0, 2, "crlNumber" }, /* 44 */
+ { 0x15, 46, 0, 2, "reasonCode" }, /* 45 */
+ { 0x17, 47, 0, 2, "holdInstructionCode" }, /* 46 */
+ { 0x18, 48, 0, 2, "invalidityDate" }, /* 47 */
+ { 0x1B, 49, 0, 2, "deltaCrlIndicator" }, /* 48 */
+ { 0x1C, 50, 0, 2, "issuingDistributionPoint" }, /* 49 */
+ { 0x1D, 51, 0, 2, "certificateIssuer" }, /* 50 */
+ { 0x1E, 52, 0, 2, "nameConstraints" }, /* 51 */
+ { 0x1F, 53, 0, 2, "crlDistributionPoints" }, /* 52 */
+ { 0x20, 55, 1, 2, "certificatePolicies" }, /* 53 */
+ { 0x00, 0, 0, 3, "anyPolicy" }, /* 54 */
+ { 0x21, 56, 0, 2, "policyMappings" }, /* 55 */
+ { 0x23, 57, 0, 2, "authorityKeyIdentifier" }, /* 56 */
+ { 0x24, 58, 0, 2, "policyConstraints" }, /* 57 */
+ { 0x25, 60, 1, 2, "extendedKeyUsage" }, /* 58 */
+ { 0x00, 0, 0, 3, "anyExtendedKeyUsage" }, /* 59 */
+ { 0x2E, 61, 0, 2, "freshestCRL" }, /* 60 */
+ { 0x36, 62, 0, 2, "inhibitAnyPolicy" }, /* 61 */
+ { 0x37, 63, 0, 2, "targetInformation" }, /* 62 */
+ { 0x38, 0, 0, 2, "noRevAvail" }, /* 63 */
+ {0x2A, 161, 1, 0, "" }, /* 64 */
+ { 0x83, 77, 1, 1, "" }, /* 65 */
+ { 0x08, 0, 1, 2, "jp" }, /* 66 */
+ { 0x8C, 0, 1, 3, "" }, /* 67 */
+ { 0x9A, 0, 1, 4, "" }, /* 68 */
+ { 0x4B, 0, 1, 5, "" }, /* 69 */
+ { 0x3D, 0, 1, 6, "" }, /* 70 */
+ { 0x01, 0, 1, 7, "security" }, /* 71 */
+ { 0x01, 0, 1, 8, "algorithm" }, /* 72 */
+ { 0x01, 0, 1, 9, "symm-encryption-alg" }, /* 73 */
+ { 0x02, 75, 0, 10, "camellia128-cbc" }, /* 74 */
+ { 0x03, 76, 0, 10, "camellia192-cbc" }, /* 75 */
+ { 0x04, 0, 0, 10, "camellia256-cbc" }, /* 76 */
+ { 0x86, 0, 1, 1, "" }, /* 77 */
+ { 0x48, 0, 1, 2, "us" }, /* 78 */
+ { 0x86, 120, 1, 3, "" }, /* 79 */
+ { 0xF6, 85, 1, 4, "" }, /* 80 */
+ { 0x7D, 0, 1, 5, "NortelNetworks" }, /* 81 */
+ { 0x07, 0, 1, 6, "Entrust" }, /* 82 */
+ { 0x41, 0, 1, 7, "nsn-ce" }, /* 83 */
+ { 0x00, 0, 0, 8, "entrustVersInfo" }, /* 84 */
+ { 0xF7, 0, 1, 4, "" }, /* 85 */
+ { 0x0D, 0, 1, 5, "RSADSI" }, /* 86 */
+ { 0x01, 115, 1, 6, "PKCS" }, /* 87 */
+ { 0x01, 97, 1, 7, "PKCS-1" }, /* 88 */
+ { 0x01, 90, 0, 8, "rsaEncryption" }, /* 89 */
+ { 0x02, 91, 0, 8, "md2WithRSAEncryption" }, /* 90 */
+ { 0x04, 92, 0, 8, "md5WithRSAEncryption" }, /* 91 */
+ { 0x05, 93, 0, 8, "sha-1WithRSAEncryption" }, /* 92 */
+ { 0x0B, 94, 0, 8, "sha256WithRSAEncryption" }, /* 93 */
+ { 0x0C, 95, 0, 8, "sha384WithRSAEncryption" }, /* 94 */
+ { 0x0D, 96, 0, 8, "sha512WithRSAEncryption" }, /* 95 */
+ { 0x0E, 0, 0, 8, "sha224WithRSAEncryption" }, /* 96 */
+ { 0x07, 104, 1, 7, "PKCS-7" }, /* 97 */
+ { 0x01, 99, 0, 8, "data" }, /* 98 */
+ { 0x02, 100, 0, 8, "signedData" }, /* 99 */
+ { 0x03, 101, 0, 8, "envelopedData" }, /* 100 */
+ { 0x04, 102, 0, 8, "signedAndEnvelopedData" }, /* 101 */
+ { 0x05, 103, 0, 8, "digestedData" }, /* 102 */
+ { 0x06, 0, 0, 8, "encryptedData" }, /* 103 */
+ { 0x09, 0, 1, 7, "PKCS-9" }, /* 104 */
+ { 0x01, 106, 0, 8, "E" }, /* 105 */
+ { 0x02, 107, 0, 8, "unstructuredName" }, /* 106 */
+ { 0x03, 108, 0, 8, "contentType" }, /* 107 */
+ { 0x04, 109, 0, 8, "messageDigest" }, /* 108 */
+ { 0x05, 110, 0, 8, "signingTime" }, /* 109 */
+ { 0x06, 111, 0, 8, "counterSignature" }, /* 110 */
+ { 0x07, 112, 0, 8, "challengePassword" }, /* 111 */
+ { 0x08, 113, 0, 8, "unstructuredAddress" }, /* 112 */
+ { 0x0E, 114, 0, 8, "extensionRequest" }, /* 113 */
+ { 0x0F, 0, 0, 8, "S/MIME Capabilities" }, /* 114 */
+ { 0x02, 118, 1, 6, "digestAlgorithm" }, /* 115 */
+ { 0x02, 117, 0, 7, "md2" }, /* 116 */
+ { 0x05, 0, 0, 7, "md5" }, /* 117 */
+ { 0x03, 0, 1, 6, "encryptionAlgorithm" }, /* 118 */
+ { 0x07, 0, 0, 7, "3des-ede-cbc" }, /* 119 */
+ { 0xCE, 0, 1, 3, "" }, /* 120 */
+ { 0x3D, 0, 1, 4, "ansi-X9-62" }, /* 121 */
+ { 0x02, 124, 1, 5, "id-publicKeyType" }, /* 122 */
+ { 0x01, 0, 0, 6, "id-ecPublicKey" }, /* 123 */
+ { 0x03, 154, 1, 5, "ellipticCurve" }, /* 124 */
+ { 0x00, 146, 1, 6, "c-TwoCurve" }, /* 125 */
+ { 0x01, 127, 0, 7, "c2pnb163v1" }, /* 126 */
+ { 0x02, 128, 0, 7, "c2pnb163v2" }, /* 127 */
+ { 0x03, 129, 0, 7, "c2pnb163v3" }, /* 128 */
+ { 0x04, 130, 0, 7, "c2pnb176w1" }, /* 129 */
+ { 0x05, 131, 0, 7, "c2tnb191v1" }, /* 130 */
+ { 0x06, 132, 0, 7, "c2tnb191v2" }, /* 131 */
+ { 0x07, 133, 0, 7, "c2tnb191v3" }, /* 132 */
+ { 0x08, 134, 0, 7, "c2onb191v4" }, /* 133 */
+ { 0x09, 135, 0, 7, "c2onb191v5" }, /* 134 */
+ { 0x0A, 136, 0, 7, "c2pnb208w1" }, /* 135 */
+ { 0x0B, 137, 0, 7, "c2tnb239v1" }, /* 136 */
+ { 0x0C, 138, 0, 7, "c2tnb239v2" }, /* 137 */
+ { 0x0D, 139, 0, 7, "c2tnb239v3" }, /* 138 */
+ { 0x0E, 140, 0, 7, "c2onb239v4" }, /* 139 */
+ { 0x0F, 141, 0, 7, "c2onb239v5" }, /* 140 */
+ { 0x10, 142, 0, 7, "c2pnb272w1" }, /* 141 */
+ { 0x11, 143, 0, 7, "c2pnb304w1" }, /* 142 */
+ { 0x12, 144, 0, 7, "c2tnb359v1" }, /* 143 */
+ { 0x13, 145, 0, 7, "c2pnb368w1" }, /* 144 */
+ { 0x14, 0, 0, 7, "c2tnb431r1" }, /* 145 */
+ { 0x01, 0, 1, 6, "primeCurve" }, /* 146 */
+ { 0x01, 148, 0, 7, "prime192v1" }, /* 147 */
+ { 0x02, 149, 0, 7, "prime192v2" }, /* 148 */
+ { 0x03, 150, 0, 7, "prime192v3" }, /* 149 */
+ { 0x04, 151, 0, 7, "prime239v1" }, /* 150 */
+ { 0x05, 152, 0, 7, "prime239v2" }, /* 151 */
+ { 0x06, 153, 0, 7, "prime239v3" }, /* 152 */
+ { 0x07, 0, 0, 7, "prime256v1" }, /* 153 */
+ { 0x04, 0, 1, 5, "id-ecSigType" }, /* 154 */
+ { 0x01, 156, 0, 6, "ecdsa-with-SHA1" }, /* 155 */
+ { 0x03, 0, 1, 6, "ecdsa-with-Specified" }, /* 156 */
+ { 0x01, 158, 0, 7, "ecdsa-with-SHA224" }, /* 157 */
+ { 0x02, 159, 0, 7, "ecdsa-with-SHA256" }, /* 158 */
+ { 0x03, 160, 0, 7, "ecdsa-with-SHA384" }, /* 159 */
+ { 0x04, 0, 0, 7, "ecdsa-with-SHA512" }, /* 160 */
+ {0x2B, 312, 1, 0, "" }, /* 161 */
+ { 0x06, 226, 1, 1, "dod" }, /* 162 */
+ { 0x01, 0, 1, 2, "internet" }, /* 163 */
+ { 0x04, 186, 1, 3, "private" }, /* 164 */
+ { 0x01, 0, 1, 4, "enterprise" }, /* 165 */
+ { 0x82, 179, 1, 5, "" }, /* 166 */
+ { 0x37, 176, 1, 6, "Microsoft" }, /* 167 */
+ { 0x0A, 172, 1, 7, "" }, /* 168 */
+ { 0x03, 0, 1, 8, "" }, /* 169 */
+ { 0x03, 171, 0, 9, "msSGC" }, /* 170 */
+ { 0x04, 0, 0, 9, "msEncryptingFileSystem" }, /* 171 */
+ { 0x14, 0, 1, 7, "msEnrollmentInfrastructure"}, /* 172 */
+ { 0x02, 0, 1, 8, "msCertificateTypeExtension"}, /* 173 */
+ { 0x02, 175, 0, 9, "msSmartcardLogon" }, /* 174 */
+ { 0x03, 0, 0, 9, "msUPN" }, /* 175 */
+ { 0xA0, 0, 1, 6, "" }, /* 176 */
+ { 0x2A, 0, 1, 7, "ITA" }, /* 177 */
+ { 0x01, 0, 0, 8, "strongSwan" }, /* 178 */
+ { 0x89, 0, 1, 5, "" }, /* 179 */
+ { 0x31, 0, 1, 6, "" }, /* 180 */
+ { 0x01, 0, 1, 7, "" }, /* 181 */
+ { 0x01, 0, 1, 8, "" }, /* 182 */
+ { 0x02, 0, 1, 9, "" }, /* 183 */
+ { 0x02, 0, 1, 10, "" }, /* 184 */
+ { 0x4B, 0, 0, 11, "TCGID" }, /* 185 */
+ { 0x05, 0, 1, 3, "security" }, /* 186 */
+ { 0x05, 0, 1, 4, "mechanisms" }, /* 187 */
+ { 0x07, 0, 1, 5, "id-pkix" }, /* 188 */
+ { 0x01, 193, 1, 6, "id-pe" }, /* 189 */
+ { 0x01, 191, 0, 7, "authorityInfoAccess" }, /* 190 */
+ { 0x03, 192, 0, 7, "qcStatements" }, /* 191 */
+ { 0x07, 0, 0, 7, "ipAddrBlocks" }, /* 192 */
+ { 0x02, 196, 1, 6, "id-qt" }, /* 193 */
+ { 0x01, 195, 0, 7, "cps" }, /* 194 */
+ { 0x02, 0, 0, 7, "unotice" }, /* 195 */
+ { 0x03, 206, 1, 6, "id-kp" }, /* 196 */
+ { 0x01, 198, 0, 7, "serverAuth" }, /* 197 */
+ { 0x02, 199, 0, 7, "clientAuth" }, /* 198 */
+ { 0x03, 200, 0, 7, "codeSigning" }, /* 199 */
+ { 0x04, 201, 0, 7, "emailProtection" }, /* 200 */
+ { 0x05, 202, 0, 7, "ipsecEndSystem" }, /* 201 */
+ { 0x06, 203, 0, 7, "ipsecTunnel" }, /* 202 */
+ { 0x07, 204, 0, 7, "ipsecUser" }, /* 203 */
+ { 0x08, 205, 0, 7, "timeStamping" }, /* 204 */
+ { 0x09, 0, 0, 7, "ocspSigning" }, /* 205 */
+ { 0x08, 208, 1, 6, "id-otherNames" }, /* 206 */
+ { 0x05, 0, 0, 7, "xmppAddr" }, /* 207 */
+ { 0x0A, 213, 1, 6, "id-aca" }, /* 208 */
+ { 0x01, 210, 0, 7, "authenticationInfo" }, /* 209 */
+ { 0x02, 211, 0, 7, "accessIdentity" }, /* 210 */
+ { 0x03, 212, 0, 7, "chargingIdentity" }, /* 211 */
+ { 0x04, 0, 0, 7, "group" }, /* 212 */
+ { 0x0B, 214, 0, 6, "subjectInfoAccess" }, /* 213 */
+ { 0x30, 0, 1, 6, "id-ad" }, /* 214 */
+ { 0x01, 223, 1, 7, "ocsp" }, /* 215 */
+ { 0x01, 217, 0, 8, "basic" }, /* 216 */
+ { 0x02, 218, 0, 8, "nonce" }, /* 217 */
+ { 0x03, 219, 0, 8, "crl" }, /* 218 */
+ { 0x04, 220, 0, 8, "response" }, /* 219 */
+ { 0x05, 221, 0, 8, "noCheck" }, /* 220 */
+ { 0x06, 222, 0, 8, "archiveCutoff" }, /* 221 */
+ { 0x07, 0, 0, 8, "serviceLocator" }, /* 222 */
+ { 0x02, 224, 0, 7, "caIssuers" }, /* 223 */
+ { 0x03, 225, 0, 7, "timeStamping" }, /* 224 */
+ { 0x05, 0, 0, 7, "caRepository" }, /* 225 */
+ { 0x0E, 232, 1, 1, "oiw" }, /* 226 */
+ { 0x03, 0, 1, 2, "secsig" }, /* 227 */
+ { 0x02, 0, 1, 3, "algorithms" }, /* 228 */
+ { 0x07, 230, 0, 4, "des-cbc" }, /* 229 */
+ { 0x1A, 231, 0, 4, "sha-1" }, /* 230 */
+ { 0x1D, 0, 0, 4, "sha-1WithRSASignature" }, /* 231 */
+ { 0x24, 278, 1, 1, "TeleTrusT" }, /* 232 */
+ { 0x03, 0, 1, 2, "algorithm" }, /* 233 */
+ { 0x03, 0, 1, 3, "signatureAlgorithm" }, /* 234 */
+ { 0x01, 239, 1, 4, "rsaSignature" }, /* 235 */
+ { 0x02, 237, 0, 5, "rsaSigWithripemd160" }, /* 236 */
+ { 0x03, 238, 0, 5, "rsaSigWithripemd128" }, /* 237 */
+ { 0x04, 0, 0, 5, "rsaSigWithripemd256" }, /* 238 */
+ { 0x02, 0, 1, 4, "ecSign" }, /* 239 */
+ { 0x01, 241, 0, 5, "ecSignWithsha1" }, /* 240 */
+ { 0x02, 242, 0, 5, "ecSignWithripemd160" }, /* 241 */
+ { 0x03, 243, 0, 5, "ecSignWithmd2" }, /* 242 */
+ { 0x04, 244, 0, 5, "ecSignWithmd5" }, /* 243 */
+ { 0x05, 261, 1, 5, "ttt-ecg" }, /* 244 */
+ { 0x01, 249, 1, 6, "fieldType" }, /* 245 */
+ { 0x01, 0, 1, 7, "characteristictwoField" }, /* 246 */
+ { 0x01, 0, 1, 8, "basisType" }, /* 247 */
+ { 0x01, 0, 0, 9, "ipBasis" }, /* 248 */
+ { 0x02, 251, 1, 6, "keyType" }, /* 249 */
+ { 0x01, 0, 0, 7, "ecgPublicKey" }, /* 250 */
+ { 0x03, 252, 0, 6, "curve" }, /* 251 */
+ { 0x04, 259, 1, 6, "signatures" }, /* 252 */
+ { 0x01, 254, 0, 7, "ecgdsa-with-RIPEMD160" }, /* 253 */
+ { 0x02, 255, 0, 7, "ecgdsa-with-SHA1" }, /* 254 */
+ { 0x03, 256, 0, 7, "ecgdsa-with-SHA224" }, /* 255 */
+ { 0x04, 257, 0, 7, "ecgdsa-with-SHA256" }, /* 256 */
+ { 0x05, 258, 0, 7, "ecgdsa-with-SHA384" }, /* 257 */
+ { 0x06, 0, 0, 7, "ecgdsa-with-SHA512" }, /* 258 */
+ { 0x05, 0, 1, 6, "module" }, /* 259 */
+ { 0x01, 0, 0, 7, "1" }, /* 260 */
+ { 0x08, 0, 1, 5, "ecStdCurvesAndGeneration" }, /* 261 */
+ { 0x01, 0, 1, 6, "ellipticCurve" }, /* 262 */
+ { 0x01, 0, 1, 7, "versionOne" }, /* 263 */
+ { 0x01, 265, 0, 8, "brainpoolP160r1" }, /* 264 */
+ { 0x02, 266, 0, 8, "brainpoolP160t1" }, /* 265 */
+ { 0x03, 267, 0, 8, "brainpoolP192r1" }, /* 266 */
+ { 0x04, 268, 0, 8, "brainpoolP192t1" }, /* 267 */
+ { 0x05, 269, 0, 8, "brainpoolP224r1" }, /* 268 */
+ { 0x06, 270, 0, 8, "brainpoolP224t1" }, /* 269 */
+ { 0x07, 271, 0, 8, "brainpoolP256r1" }, /* 270 */
+ { 0x08, 272, 0, 8, "brainpoolP256t1" }, /* 271 */
+ { 0x09, 273, 0, 8, "brainpoolP320r1" }, /* 272 */
+ { 0x0A, 274, 0, 8, "brainpoolP320t1" }, /* 273 */
+ { 0x0B, 275, 0, 8, "brainpoolP384r1" }, /* 274 */
+ { 0x0C, 276, 0, 8, "brainpoolP384t1" }, /* 275 */
+ { 0x0D, 277, 0, 8, "brainpoolP512r1" }, /* 276 */
+ { 0x0E, 0, 0, 8, "brainpoolP512t1" }, /* 277 */
+ { 0x81, 0, 1, 1, "" }, /* 278 */
+ { 0x04, 0, 1, 2, "Certicom" }, /* 279 */
+ { 0x00, 0, 1, 3, "curve" }, /* 280 */
+ { 0x01, 282, 0, 4, "sect163k1" }, /* 281 */
+ { 0x02, 283, 0, 4, "sect163r1" }, /* 282 */
+ { 0x03, 284, 0, 4, "sect239k1" }, /* 283 */
+ { 0x04, 285, 0, 4, "sect113r1" }, /* 284 */
+ { 0x05, 286, 0, 4, "sect113r2" }, /* 285 */
+ { 0x06, 287, 0, 4, "secp112r1" }, /* 286 */
+ { 0x07, 288, 0, 4, "secp112r2" }, /* 287 */
+ { 0x08, 289, 0, 4, "secp160r1" }, /* 288 */
+ { 0x09, 290, 0, 4, "secp160k1" }, /* 289 */
+ { 0x0A, 291, 0, 4, "secp256k1" }, /* 290 */
+ { 0x0F, 292, 0, 4, "sect163r2" }, /* 291 */
+ { 0x10, 293, 0, 4, "sect283k1" }, /* 292 */
+ { 0x11, 294, 0, 4, "sect283r1" }, /* 293 */
+ { 0x16, 295, 0, 4, "sect131r1" }, /* 294 */
+ { 0x17, 296, 0, 4, "sect131r2" }, /* 295 */
+ { 0x18, 297, 0, 4, "sect193r1" }, /* 296 */
+ { 0x19, 298, 0, 4, "sect193r2" }, /* 297 */
+ { 0x1A, 299, 0, 4, "sect233k1" }, /* 298 */
+ { 0x1B, 300, 0, 4, "sect233r1" }, /* 299 */
+ { 0x1C, 301, 0, 4, "secp128r1" }, /* 300 */
+ { 0x1D, 302, 0, 4, "secp128r2" }, /* 301 */
+ { 0x1E, 303, 0, 4, "secp160r2" }, /* 302 */
+ { 0x1F, 304, 0, 4, "secp192k1" }, /* 303 */
+ { 0x20, 305, 0, 4, "secp224k1" }, /* 304 */
+ { 0x21, 306, 0, 4, "secp224r1" }, /* 305 */
+ { 0x22, 307, 0, 4, "secp384r1" }, /* 306 */
+ { 0x23, 308, 0, 4, "secp521r1" }, /* 307 */
+ { 0x24, 309, 0, 4, "sect409k1" }, /* 308 */
+ { 0x25, 310, 0, 4, "sect409r1" }, /* 309 */
+ { 0x26, 311, 0, 4, "sect571k1" }, /* 310 */
+ { 0x27, 0, 0, 4, "sect571r1" }, /* 311 */
+ {0x60, 0, 1, 0, "" }, /* 312 */
+ { 0x86, 0, 1, 1, "" }, /* 313 */
+ { 0x48, 0, 1, 2, "" }, /* 314 */
+ { 0x01, 0, 1, 3, "organization" }, /* 315 */
+ { 0x65, 334, 1, 4, "gov" }, /* 316 */
+ { 0x03, 0, 1, 5, "csor" }, /* 317 */
+ { 0x04, 0, 1, 6, "nistalgorithm" }, /* 318 */
+ { 0x01, 329, 1, 7, "aes" }, /* 319 */
+ { 0x02, 321, 0, 8, "id-aes128-CBC" }, /* 320 */
+ { 0x06, 322, 0, 8, "id-aes128-GCM" }, /* 321 */
+ { 0x07, 323, 0, 8, "id-aes128-CCM" }, /* 322 */
+ { 0x16, 324, 0, 8, "id-aes192-CBC" }, /* 323 */
+ { 0x1A, 325, 0, 8, "id-aes192-GCM" }, /* 324 */
+ { 0x1B, 326, 0, 8, "id-aes192-CCM" }, /* 325 */
+ { 0x2A, 327, 0, 8, "id-aes256-CBC" }, /* 326 */
+ { 0x2E, 328, 0, 8, "id-aes256-GCM" }, /* 327 */
+ { 0x2F, 0, 0, 8, "id-aes256-CCM" }, /* 328 */
+ { 0x02, 0, 1, 7, "hashalgs" }, /* 329 */
+ { 0x01, 331, 0, 8, "id-SHA-256" }, /* 330 */
+ { 0x02, 332, 0, 8, "id-SHA-384" }, /* 331 */
+ { 0x03, 333, 0, 8, "id-SHA-512" }, /* 332 */
+ { 0x04, 0, 0, 8, "id-SHA-224" }, /* 333 */
+ { 0x86, 0, 1, 4, "" }, /* 334 */
+ { 0xf8, 0, 1, 5, "" }, /* 335 */
+ { 0x42, 348, 1, 6, "netscape" }, /* 336 */
+ { 0x01, 343, 1, 7, "" }, /* 337 */
+ { 0x01, 339, 0, 8, "nsCertType" }, /* 338 */
+ { 0x03, 340, 0, 8, "nsRevocationUrl" }, /* 339 */
+ { 0x04, 341, 0, 8, "nsCaRevocationUrl" }, /* 340 */
+ { 0x08, 342, 0, 8, "nsCaPolicyUrl" }, /* 341 */
+ { 0x0d, 0, 0, 8, "nsComment" }, /* 342 */
+ { 0x03, 346, 1, 7, "directory" }, /* 343 */
+ { 0x01, 0, 1, 8, "" }, /* 344 */
+ { 0x03, 0, 0, 9, "employeeNumber" }, /* 345 */
+ { 0x04, 0, 1, 7, "policy" }, /* 346 */
+ { 0x01, 0, 0, 8, "nsSGC" }, /* 347 */
+ { 0x45, 0, 1, 6, "verisign" }, /* 348 */
+ { 0x01, 0, 1, 7, "pki" }, /* 349 */
+ { 0x09, 0, 1, 8, "attributes" }, /* 350 */
+ { 0x02, 352, 0, 9, "messageType" }, /* 351 */
+ { 0x03, 353, 0, 9, "pkiStatus" }, /* 352 */
+ { 0x04, 354, 0, 9, "failInfo" }, /* 353 */
+ { 0x05, 355, 0, 9, "senderNonce" }, /* 354 */
+ { 0x06, 356, 0, 9, "recipientNonce" }, /* 355 */
+ { 0x07, 357, 0, 9, "transID" }, /* 356 */
+ { 0x08, 358, 0, 9, "extensionReq" }, /* 357 */
+ { 0x08, 0, 0, 9, "extensionReq" } /* 358 */
};
diff --git a/src/libstrongswan/asn1/oid.h b/src/libstrongswan/asn1/oid.h
index 16c9e854b..b6ee9a10d 100644
--- a/src/libstrongswan/asn1/oid.h
+++ b/src/libstrongswan/asn1/oid.h
@@ -49,8 +49,11 @@ extern const oid_t oid_names[];
#define OID_DELTA_CRL_INDICATOR 48
#define OID_NAME_CONSTRAINTS 51
#define OID_CRL_DISTRIBUTION_POINTS 52
+#define OID_CERTIFICATE_POLICIES 53
#define OID_ANY_POLICY 54
+#define OID_POLICY_MAPPINGS 55
#define OID_AUTHORITY_KEY_ID 56
+#define OID_POLICY_CONSTRAINTS 57
#define OID_EXTENDED_KEY_USAGE 58
#define OID_FRESHEST_CRL 60
#define OID_INHIBIT_ANY_POLICY 61
@@ -117,92 +120,95 @@ extern const oid_t oid_names[];
#define OID_ECDSA_WITH_SHA384 159
#define OID_ECDSA_WITH_SHA512 160
#define OID_USER_PRINCIPAL_NAME 175
-#define OID_TCGID 182
-#define OID_AUTHORITY_INFO_ACCESS 187
-#define OID_IP_ADDR_BLOCKS 189
-#define OID_SERVER_AUTH 194
-#define OID_CLIENT_AUTH 195
-#define OID_OCSP_SIGNING 202
-#define OID_XMPP_ADDR 204
-#define OID_AUTHENTICATION_INFO 206
-#define OID_ACCESS_IDENTITY 207
-#define OID_CHARGING_IDENTITY 208
-#define OID_GROUP 209
-#define OID_OCSP 212
-#define OID_BASIC 213
-#define OID_NONCE 214
-#define OID_CRL 215
-#define OID_RESPONSE 216
-#define OID_NO_CHECK 217
-#define OID_ARCHIVE_CUTOFF 218
-#define OID_SERVICE_LOCATOR 219
-#define OID_CA_ISSUERS 220
-#define OID_DES_CBC 226
-#define OID_SHA1 227
-#define OID_SHA1_WITH_RSA_OIW 228
-#define OID_ECGDSA_PUBKEY 247
-#define OID_ECGDSA_SIG_WITH_RIPEMD160 250
-#define OID_ECGDSA_SIG_WITH_SHA1 251
-#define OID_ECGDSA_SIG_WITH_SHA224 252
-#define OID_ECGDSA_SIG_WITH_SHA256 253
-#define OID_ECGDSA_SIG_WITH_SHA384 254
-#define OID_ECGDSA_SIG_WITH_SHA512 255
-#define OID_SECT163K1 278
-#define OID_SECT163R1 279
-#define OID_SECT239K1 280
-#define OID_SECT113R1 281
-#define OID_SECT113R2 282
-#define OID_SECT112R1 283
-#define OID_SECT112R2 284
-#define OID_SECT160R1 285
-#define OID_SECT160K1 286
-#define OID_SECT256K1 287
-#define OID_SECT163R2 288
-#define OID_SECT283K1 289
-#define OID_SECT283R1 290
-#define OID_SECT131R1 291
-#define OID_SECT131R2 292
-#define OID_SECT193R1 293
-#define OID_SECT193R2 294
-#define OID_SECT233K1 295
-#define OID_SECT233R1 296
-#define OID_SECT128R1 297
-#define OID_SECT128R2 298
-#define OID_SECT160R2 299
-#define OID_SECT192K1 300
-#define OID_SECT224K1 301
-#define OID_SECT224R1 302
-#define OID_SECT384R1 303
-#define OID_SECT521R1 304
-#define OID_SECT409K1 305
-#define OID_SECT409R1 306
-#define OID_SECT571K1 307
-#define OID_SECT571R1 308
-#define OID_AES128_CBC 317
-#define OID_AES128_GCM 318
-#define OID_AES128_CCM 319
-#define OID_AES192_CBC 320
-#define OID_AES192_GCM 321
-#define OID_AES192_CCM 322
-#define OID_AES256_CBC 323
-#define OID_AES256_GCM 324
-#define OID_AES256_CCM 325
-#define OID_SHA256 327
-#define OID_SHA384 328
-#define OID_SHA512 329
-#define OID_SHA224 330
-#define OID_NS_REVOCATION_URL 336
-#define OID_NS_CA_REVOCATION_URL 337
-#define OID_NS_CA_POLICY_URL 338
-#define OID_NS_COMMENT 339
-#define OID_EMPLOYEE_NUMBER 342
-#define OID_PKI_MESSAGE_TYPE 348
-#define OID_PKI_STATUS 349
-#define OID_PKI_FAIL_INFO 350
-#define OID_PKI_SENDER_NONCE 351
-#define OID_PKI_RECIPIENT_NONCE 352
-#define OID_PKI_TRANS_ID 353
+#define OID_STRONGSWAN 178
+#define OID_TCGID 185
+#define OID_AUTHORITY_INFO_ACCESS 190
+#define OID_IP_ADDR_BLOCKS 192
+#define OID_POLICY_QUALIFIER_CPS 194
+#define OID_POLICY_QUALIFIER_UNOTICE 195
+#define OID_SERVER_AUTH 197
+#define OID_CLIENT_AUTH 198
+#define OID_OCSP_SIGNING 205
+#define OID_XMPP_ADDR 207
+#define OID_AUTHENTICATION_INFO 209
+#define OID_ACCESS_IDENTITY 210
+#define OID_CHARGING_IDENTITY 211
+#define OID_GROUP 212
+#define OID_OCSP 215
+#define OID_BASIC 216
+#define OID_NONCE 217
+#define OID_CRL 218
+#define OID_RESPONSE 219
+#define OID_NO_CHECK 220
+#define OID_ARCHIVE_CUTOFF 221
+#define OID_SERVICE_LOCATOR 222
+#define OID_CA_ISSUERS 223
+#define OID_DES_CBC 229
+#define OID_SHA1 230
+#define OID_SHA1_WITH_RSA_OIW 231
+#define OID_ECGDSA_PUBKEY 250
+#define OID_ECGDSA_SIG_WITH_RIPEMD160 253
+#define OID_ECGDSA_SIG_WITH_SHA1 254
+#define OID_ECGDSA_SIG_WITH_SHA224 255
+#define OID_ECGDSA_SIG_WITH_SHA256 256
+#define OID_ECGDSA_SIG_WITH_SHA384 257
+#define OID_ECGDSA_SIG_WITH_SHA512 258
+#define OID_SECT163K1 281
+#define OID_SECT163R1 282
+#define OID_SECT239K1 283
+#define OID_SECT113R1 284
+#define OID_SECT113R2 285
+#define OID_SECT112R1 286
+#define OID_SECT112R2 287
+#define OID_SECT160R1 288
+#define OID_SECT160K1 289
+#define OID_SECT256K1 290
+#define OID_SECT163R2 291
+#define OID_SECT283K1 292
+#define OID_SECT283R1 293
+#define OID_SECT131R1 294
+#define OID_SECT131R2 295
+#define OID_SECT193R1 296
+#define OID_SECT193R2 297
+#define OID_SECT233K1 298
+#define OID_SECT233R1 299
+#define OID_SECT128R1 300
+#define OID_SECT128R2 301
+#define OID_SECT160R2 302
+#define OID_SECT192K1 303
+#define OID_SECT224K1 304
+#define OID_SECT224R1 305
+#define OID_SECT384R1 306
+#define OID_SECT521R1 307
+#define OID_SECT409K1 308
+#define OID_SECT409R1 309
+#define OID_SECT571K1 310
+#define OID_SECT571R1 311
+#define OID_AES128_CBC 320
+#define OID_AES128_GCM 321
+#define OID_AES128_CCM 322
+#define OID_AES192_CBC 323
+#define OID_AES192_GCM 324
+#define OID_AES192_CCM 325
+#define OID_AES256_CBC 326
+#define OID_AES256_GCM 327
+#define OID_AES256_CCM 328
+#define OID_SHA256 330
+#define OID_SHA384 331
+#define OID_SHA512 332
+#define OID_SHA224 333
+#define OID_NS_REVOCATION_URL 339
+#define OID_NS_CA_REVOCATION_URL 340
+#define OID_NS_CA_POLICY_URL 341
+#define OID_NS_COMMENT 342
+#define OID_EMPLOYEE_NUMBER 345
+#define OID_PKI_MESSAGE_TYPE 351
+#define OID_PKI_STATUS 352
+#define OID_PKI_FAIL_INFO 353
+#define OID_PKI_SENDER_NONCE 354
+#define OID_PKI_RECIPIENT_NONCE 355
+#define OID_PKI_TRANS_ID 356
-#define OID_MAX 356
+#define OID_MAX 359
#endif /* OID_H_ */
diff --git a/src/libstrongswan/asn1/oid.txt b/src/libstrongswan/asn1/oid.txt
index 36db0299c..e2931c7dd 100644
--- a/src/libstrongswan/asn1/oid.txt
+++ b/src/libstrongswan/asn1/oid.txt
@@ -51,11 +51,11 @@
0x1D "certificateIssuer"
0x1E "nameConstraints" OID_NAME_CONSTRAINTS
0x1F "crlDistributionPoints" OID_CRL_DISTRIBUTION_POINTS
- 0x20 "certificatePolicies"
+ 0x20 "certificatePolicies" OID_CERTIFICATE_POLICIES
0x00 "anyPolicy" OID_ANY_POLICY
- 0x21 "policyMappings"
+ 0x21 "policyMappings" OID_POLICY_MAPPINGS
0x23 "authorityKeyIdentifier" OID_AUTHORITY_KEY_ID
- 0x24 "policyConstraints"
+ 0x24 "policyConstraints" OID_POLICY_CONSTRAINTS
0x25 "extendedKeyUsage" OID_EXTENDED_KEY_USAGE
0x00 "anyExtendedKeyUsage"
0x2E "freshestCRL" OID_FRESHEST_CRL
@@ -124,7 +124,7 @@
0x01 "id-ecPublicKey" OID_EC_PUBLICKEY
0x03 "ellipticCurve"
0x00 "c-TwoCurve"
- 0x01 "c2pnb163v1" OID_C2PNB163V1
+ 0x01 "c2pnb163v1" OID_C2PNB163V1
0x02 "c2pnb163v2" OID_C2PNB163V2
0x03 "c2pnb163v3" OID_C2PNB163V3
0x04 "c2pnb176w1" OID_C2PNB176W1
@@ -174,13 +174,16 @@
0x02 "msCertificateTypeExtension"
0x02 "msSmartcardLogon"
0x03 "msUPN" OID_USER_PRINCIPAL_NAME
+ 0xA0 ""
+ 0x2A "ITA"
+ 0x01 "strongSwan" OID_STRONGSWAN
0x89 ""
0x31 ""
0x01 ""
0x01 ""
0x02 ""
0x02 ""
- 0x4B "TCGID" OID_TCGID
+ 0x4B "TCGID" OID_TCGID
0x05 "security"
0x05 "mechanisms"
0x07 "id-pkix"
@@ -189,8 +192,8 @@
0x03 "qcStatements"
0x07 "ipAddrBlocks" OID_IP_ADDR_BLOCKS
0x02 "id-qt"
- 0x01 "cps"
- 0x02 "unotice"
+ 0x01 "cps" OID_POLICY_QUALIFIER_CPS
+ 0x02 "unotice" OID_POLICY_QUALIFIER_UNOTICE
0x03 "id-kp"
0x01 "serverAuth" OID_SERVER_AUTH
0x02 "clientAuth" OID_CLIENT_AUTH
diff --git a/src/libstrongswan/credentials/auth_cfg.c b/src/libstrongswan/credentials/auth_cfg.c
index ce718b9cb..23a3f62d9 100644
--- a/src/libstrongswan/credentials/auth_cfg.c
+++ b/src/libstrongswan/credentials/auth_cfg.c
@@ -131,11 +131,13 @@ static void destroy_entry_value(entry_t *entry)
case AUTH_RULE_SUBJECT_CERT:
case AUTH_HELPER_IM_CERT:
case AUTH_HELPER_SUBJECT_CERT:
+ case AUTH_HELPER_REVOCATION_CERT:
{
certificate_t *cert = (certificate_t*)entry->value;
cert->destroy(cert);
break;
}
+ case AUTH_RULE_CERT_POLICY:
case AUTH_HELPER_IM_HASH_URL:
case AUTH_HELPER_SUBJECT_HASH_URL:
{
@@ -147,6 +149,8 @@ static void destroy_entry_value(entry_t *entry)
case AUTH_RULE_EAP_VENDOR:
case AUTH_RULE_CRL_VALIDATION:
case AUTH_RULE_OCSP_VALIDATION:
+ case AUTH_RULE_RSA_STRENGTH:
+ case AUTH_RULE_ECDSA_STRENGTH:
break;
}
}
@@ -172,6 +176,8 @@ static void replace(auth_cfg_t *this, entry_enumerator_t *enumerator,
case AUTH_RULE_EAP_VENDOR:
case AUTH_RULE_CRL_VALIDATION:
case AUTH_RULE_OCSP_VALIDATION:
+ case AUTH_RULE_RSA_STRENGTH:
+ case AUTH_RULE_ECDSA_STRENGTH:
/* integer type */
enumerator->current->value = (void*)(uintptr_t)va_arg(args, u_int);
break;
@@ -182,10 +188,12 @@ static void replace(auth_cfg_t *this, entry_enumerator_t *enumerator,
case AUTH_RULE_CA_CERT:
case AUTH_RULE_IM_CERT:
case AUTH_RULE_SUBJECT_CERT:
+ case AUTH_RULE_CERT_POLICY:
case AUTH_HELPER_IM_CERT:
case AUTH_HELPER_SUBJECT_CERT:
case AUTH_HELPER_IM_HASH_URL:
case AUTH_HELPER_SUBJECT_HASH_URL:
+ case AUTH_HELPER_REVOCATION_CERT:
/* pointer type */
enumerator->current->value = va_arg(args, void*);
break;
@@ -237,6 +245,8 @@ static void* get(private_auth_cfg_t *this, auth_rule_t type)
case AUTH_RULE_EAP_TYPE:
return (void*)EAP_NAK;
case AUTH_RULE_EAP_VENDOR:
+ case AUTH_RULE_RSA_STRENGTH:
+ case AUTH_RULE_ECDSA_STRENGTH:
return (void*)0;
case AUTH_RULE_CRL_VALIDATION:
case AUTH_RULE_OCSP_VALIDATION:
@@ -248,10 +258,12 @@ static void* get(private_auth_cfg_t *this, auth_rule_t type)
case AUTH_RULE_CA_CERT:
case AUTH_RULE_IM_CERT:
case AUTH_RULE_SUBJECT_CERT:
+ case AUTH_RULE_CERT_POLICY:
case AUTH_HELPER_IM_CERT:
case AUTH_HELPER_SUBJECT_CERT:
case AUTH_HELPER_IM_HASH_URL:
case AUTH_HELPER_SUBJECT_HASH_URL:
+ case AUTH_HELPER_REVOCATION_CERT:
default:
return NULL;
}
@@ -274,6 +286,8 @@ static void add(private_auth_cfg_t *this, auth_rule_t type, ...)
case AUTH_RULE_EAP_VENDOR:
case AUTH_RULE_CRL_VALIDATION:
case AUTH_RULE_OCSP_VALIDATION:
+ case AUTH_RULE_RSA_STRENGTH:
+ case AUTH_RULE_ECDSA_STRENGTH:
/* integer type */
entry->value = (void*)(uintptr_t)va_arg(args, u_int);
break;
@@ -284,10 +298,12 @@ static void add(private_auth_cfg_t *this, auth_rule_t type, ...)
case AUTH_RULE_CA_CERT:
case AUTH_RULE_IM_CERT:
case AUTH_RULE_SUBJECT_CERT:
+ case AUTH_RULE_CERT_POLICY:
case AUTH_HELPER_IM_CERT:
case AUTH_HELPER_SUBJECT_CERT:
case AUTH_HELPER_IM_HASH_URL:
case AUTH_HELPER_SUBJECT_HASH_URL:
+ case AUTH_HELPER_REVOCATION_CERT:
/* pointer type */
entry->value = va_arg(args, void*);
break;
@@ -358,38 +374,45 @@ static bool complies(private_auth_cfg_t *this, auth_cfg_t *constraints,
case AUTH_RULE_CRL_VALIDATION:
case AUTH_RULE_OCSP_VALIDATION:
{
- cert_validation_t validated, required;
+ uintptr_t validated;
- required = (uintptr_t)value;
- validated = (uintptr_t)get(this, t1);
- switch (required)
+ e2 = create_enumerator(this);
+ while (e2->enumerate(e2, &t2, &validated))
{
- case VALIDATION_FAILED:
- /* no constraint */
- break;
- case VALIDATION_SKIPPED:
- if (validated == VALIDATION_SKIPPED)
- {
- break;
- }
- /* FALL */
- case VALIDATION_GOOD:
- if (validated == VALIDATION_GOOD)
- {
- break;
- }
- /* FALL */
- default:
- success = FALSE;
- if (log_error)
+ if (t2 == t1)
+ {
+ switch ((uintptr_t)value)
{
- DBG1(DBG_CFG, "constraint check failed: %N is %N, "
- "but requires at least %N", auth_rule_names,
- t1, cert_validation_names, validated,
- cert_validation_names, required);
+ case VALIDATION_FAILED:
+ /* no constraint */
+ break;
+ case VALIDATION_SKIPPED:
+ if (validated == VALIDATION_SKIPPED)
+ {
+ break;
+ }
+ /* FALL */
+ case VALIDATION_GOOD:
+ if (validated == VALIDATION_GOOD)
+ {
+ break;
+ }
+ /* FALL */
+ default:
+ success = FALSE;
+ if (log_error)
+ {
+ DBG1(DBG_CFG, "constraint check failed: "
+ "%N is %N, but requires at least %N",
+ auth_rule_names, t1,
+ cert_validation_names, validated,
+ cert_validation_names, (uintptr_t)value);
+ }
+ break;
}
- break;
+ }
}
+ e2->destroy(e2);
break;
}
case AUTH_RULE_IDENTITY:
@@ -473,10 +496,76 @@ static bool complies(private_auth_cfg_t *this, auth_cfg_t *constraints,
e2->destroy(e2);
break;
}
+ case AUTH_RULE_RSA_STRENGTH:
+ case AUTH_RULE_ECDSA_STRENGTH:
+ {
+ uintptr_t strength;
+
+ e2 = create_enumerator(this);
+ while (e2->enumerate(e2, &t2, &strength))
+ {
+ if (t2 == t1)
+ {
+ if ((uintptr_t)value > strength)
+ {
+ success = FALSE;
+ if (log_error)
+ {
+ DBG1(DBG_CFG, "constraint requires %d bit "
+ "public keys, but %d bit key used",
+ (uintptr_t)value, strength);
+ }
+ }
+ }
+ else if (t2 == AUTH_RULE_RSA_STRENGTH)
+ {
+ success = FALSE;
+ if (log_error)
+ {
+ DBG1(DBG_CFG, "constraint requires %d bit ECDSA, "
+ "but RSA used", (uintptr_t)value);
+ }
+ }
+ else if (t2 == AUTH_RULE_ECDSA_STRENGTH)
+ {
+ success = FALSE;
+ if (log_error)
+ {
+ DBG1(DBG_CFG, "constraint requires %d bit RSA, "
+ "but ECDSA used", (uintptr_t)value);
+ }
+ }
+ }
+ e2->destroy(e2);
+ break;
+ }
+ case AUTH_RULE_CERT_POLICY:
+ {
+ char *oid1, *oid2;
+
+ oid1 = (char*)value;
+ success = FALSE;
+ e2 = create_enumerator(this);
+ while (e2->enumerate(e2, &t2, &oid2))
+ {
+ if (t2 == t1 && streq(oid1, oid2))
+ {
+ success = TRUE;
+ break;
+ }
+ }
+ e2->destroy(e2);
+ if (!success && log_error)
+ {
+ DBG1(DBG_CFG, "constraint requires cert policy %s", oid1);
+ }
+ break;
+ }
case AUTH_HELPER_IM_CERT:
case AUTH_HELPER_SUBJECT_CERT:
case AUTH_HELPER_IM_HASH_URL:
case AUTH_HELPER_SUBJECT_HASH_URL:
+ case AUTH_HELPER_REVOCATION_CERT:
/* skip helpers */
continue;
}
@@ -523,6 +612,7 @@ static void merge(private_auth_cfg_t *this, private_auth_cfg_t *other, bool copy
case AUTH_RULE_SUBJECT_CERT:
case AUTH_HELPER_IM_CERT:
case AUTH_HELPER_SUBJECT_CERT:
+ case AUTH_HELPER_REVOCATION_CERT:
{
certificate_t *cert = (certificate_t*)value;
@@ -534,6 +624,8 @@ static void merge(private_auth_cfg_t *this, private_auth_cfg_t *other, bool copy
case AUTH_RULE_AUTH_CLASS:
case AUTH_RULE_EAP_TYPE:
case AUTH_RULE_EAP_VENDOR:
+ case AUTH_RULE_RSA_STRENGTH:
+ case AUTH_RULE_ECDSA_STRENGTH:
{
add(this, type, (uintptr_t)value);
break;
@@ -548,6 +640,7 @@ static void merge(private_auth_cfg_t *this, private_auth_cfg_t *other, bool copy
add(this, type, id->clone(id));
break;
}
+ case AUTH_RULE_CERT_POLICY:
case AUTH_HELPER_IM_HASH_URL:
case AUTH_HELPER_SUBJECT_HASH_URL:
{
@@ -600,6 +693,8 @@ static bool equals(private_auth_cfg_t *this, private_auth_cfg_t *other)
case AUTH_RULE_EAP_VENDOR:
case AUTH_RULE_CRL_VALIDATION:
case AUTH_RULE_OCSP_VALIDATION:
+ case AUTH_RULE_RSA_STRENGTH:
+ case AUTH_RULE_ECDSA_STRENGTH:
{
if (i1->value == i2->value)
{
@@ -613,6 +708,7 @@ static bool equals(private_auth_cfg_t *this, private_auth_cfg_t *other)
case AUTH_RULE_SUBJECT_CERT:
case AUTH_HELPER_IM_CERT:
case AUTH_HELPER_SUBJECT_CERT:
+ case AUTH_HELPER_REVOCATION_CERT:
{
certificate_t *c1, *c2;
@@ -643,6 +739,7 @@ static bool equals(private_auth_cfg_t *this, private_auth_cfg_t *other)
}
continue;
}
+ case AUTH_RULE_CERT_POLICY:
case AUTH_HELPER_IM_HASH_URL:
case AUTH_HELPER_SUBJECT_HASH_URL:
{
@@ -725,11 +822,13 @@ static auth_cfg_t* clone_(private_auth_cfg_t *this)
case AUTH_RULE_SUBJECT_CERT:
case AUTH_HELPER_IM_CERT:
case AUTH_HELPER_SUBJECT_CERT:
+ case AUTH_HELPER_REVOCATION_CERT:
{
certificate_t *cert = (certificate_t*)entry->value;
clone->add(clone, entry->type, cert->get_ref(cert));
break;
}
+ case AUTH_RULE_CERT_POLICY:
case AUTH_HELPER_IM_HASH_URL:
case AUTH_HELPER_SUBJECT_HASH_URL:
{
@@ -741,6 +840,8 @@ static auth_cfg_t* clone_(private_auth_cfg_t *this)
case AUTH_RULE_EAP_VENDOR:
case AUTH_RULE_CRL_VALIDATION:
case AUTH_RULE_OCSP_VALIDATION:
+ case AUTH_RULE_RSA_STRENGTH:
+ case AUTH_RULE_ECDSA_STRENGTH:
clone->add(clone, entry->type, (uintptr_t)entry->value);
break;
}
diff --git a/src/libstrongswan/credentials/auth_cfg.h b/src/libstrongswan/credentials/auth_cfg.h
index 19624a2fe..489ce1134 100644
--- a/src/libstrongswan/credentials/auth_cfg.h
+++ b/src/libstrongswan/credentials/auth_cfg.h
@@ -90,6 +90,12 @@ enum auth_rule_t {
* The group membership constraint is fulfilled if the subject is member of
* one group defined in the constraints. */
AUTH_RULE_GROUP,
+ /** required RSA public key strength, u_int in bits */
+ AUTH_RULE_RSA_STRENGTH,
+ /** required ECDSA public key strength, u_int in bits */
+ AUTH_RULE_ECDSA_STRENGTH,
+ /** certificatePolicy constraint, numerical OID as char* */
+ AUTH_RULE_CERT_POLICY,
/** intermediate certificate, certificate_t* */
AUTH_HELPER_IM_CERT,
@@ -99,6 +105,8 @@ enum auth_rule_t {
AUTH_HELPER_IM_HASH_URL,
/** Hash and URL of a end-entity certificate, char* */
AUTH_HELPER_SUBJECT_HASH_URL,
+ /** revocation certificate (CRL, OCSP), certificate_t* */
+ AUTH_HELPER_REVOCATION_CERT,
};
/**
diff --git a/src/libstrongswan/credentials/builder.c b/src/libstrongswan/credentials/builder.c
index c43e5fd5d..f9a277a2c 100644
--- a/src/libstrongswan/credentials/builder.c
+++ b/src/libstrongswan/credentials/builder.c
@@ -43,8 +43,16 @@ ENUM(builder_part_names, BUILD_FROM_FILE, BUILD_END,
"BUILD_CRL_DISTRIBUTION_POINTS",
"BUILD_OCSP_ACCESS_LOCATIONS",
"BUILD_PATHLEN",
+ "BUILD_PERMITTED_NAME_CONSTRAINTS",
+ "BUILD_EXCLUDED_NAME_CONSTRAINTS",
+ "BUILD_CERTIFICATE_POLICIES",
+ "BUILD_POLICY_MAPPINGS",
+ "BUILD_POLICY_REQUIRE_EXPLICIT",
+ "BUILD_POLICY_INHIBIT_MAPPING",
+ "BUILD_POLICY_INHIBIT_ANY",
"BUILD_X509_FLAG",
"BUILD_REVOKED_ENUMERATOR",
+ "BUILD_BASE_CRL",
"BUILD_CHALLENGE_PWD",
"BUILD_PKCS11_MODULE",
"BUILD_PKCS11_SLOT",
diff --git a/src/libstrongswan/credentials/builder.h b/src/libstrongswan/credentials/builder.h
index dc87da2a4..325b668cd 100644
--- a/src/libstrongswan/credentials/builder.h
+++ b/src/libstrongswan/credentials/builder.h
@@ -87,16 +87,32 @@ enum builder_part_t {
BUILD_CA_CERT,
/** a certificate, certificate_t* */
BUILD_CERT,
- /** CRL distribution point URIs, linked_list_t* containing char* */
+ /** CRL distribution point URIs, x509_cdp_t* */
BUILD_CRL_DISTRIBUTION_POINTS,
/** OCSP AuthorityInfoAccess locations, linked_list_t* containing char* */
BUILD_OCSP_ACCESS_LOCATIONS,
/** certificate path length constraint */
BUILD_PATHLEN,
+ /** permitted X509 name constraints, linked_list_t* of identification_t* */
+ BUILD_PERMITTED_NAME_CONSTRAINTS,
+ /** excluded X509 name constraints, linked_list_t* of identification_t* */
+ BUILD_EXCLUDED_NAME_CONSTRAINTS,
+ /** certificatePolicy OIDs, linked_list_t* of x509_cert_policy_t* */
+ BUILD_CERTIFICATE_POLICIES,
+ /** policyMapping OIDs, linked_list_t* of x509_policy_mapping_t* */
+ BUILD_POLICY_MAPPINGS,
+ /** requireExplicitPolicy constraint, int */
+ BUILD_POLICY_REQUIRE_EXPLICIT,
+ /** inhibitPolicyMapping constraint, int */
+ BUILD_POLICY_INHIBIT_MAPPING,
+ /** inhibitAnyPolicy constraint, int */
+ BUILD_POLICY_INHIBIT_ANY,
/** enforce an additional X509 flag, x509_flag_t */
BUILD_X509_FLAG,
/** enumerator_t over (chunk_t serial, time_t date, crl_reason_t reason) */
BUILD_REVOKED_ENUMERATOR,
+ /** Base CRL serial for a delta CRL, chunk_t, */
+ BUILD_BASE_CRL,
/** PKCS#10 challenge password */
BUILD_CHALLENGE_PWD,
/** friendly name of a PKCS#11 module, null terminated char* */
diff --git a/src/libstrongswan/credentials/cert_validator.h b/src/libstrongswan/credentials/cert_validator.h
index 1e67c23ab..733d9d612 100644
--- a/src/libstrongswan/credentials/cert_validator.h
+++ b/src/libstrongswan/credentials/cert_validator.h
@@ -40,12 +40,13 @@ struct cert_validator_t {
* @param subject subject certificate to check
* @param issuer issuer of subject
* @param online wheter to do online revocation checking
- * @param pathlen the current length of the path up to the root CA
+ * @param pathlen the current length of the path bottom-up
+ * @param anchor is issuer trusted root anchor
* @param auth container for resulting authentication info
*/
bool (*validate)(cert_validator_t *this, certificate_t *subject,
- certificate_t *issuer, bool online, int pathlen,
- auth_cfg_t *auth);
+ certificate_t *issuer, bool online, u_int pathlen,
+ bool anchor, auth_cfg_t *auth);
};
#endif /** CERT_VALIDATOR_H_ @}*/
diff --git a/src/libstrongswan/credentials/certificates/crl.h b/src/libstrongswan/credentials/certificates/crl.h
index 9425311fb..2f3497474 100644
--- a/src/libstrongswan/credentials/certificates/crl.h
+++ b/src/libstrongswan/credentials/certificates/crl.h
@@ -72,6 +72,21 @@ struct crl_t {
chunk_t (*get_authKeyIdentifier)(crl_t *this);
/**
+ * Is this CRL a delta CRL?
+ *
+ * @param base_crl gets to baseCrlNumber, if this is a delta CRL
+ * @return TRUE if delta CRL
+ */
+ bool (*is_delta_crl)(crl_t *this, chunk_t *base_crl);
+
+ /**
+ * Create an enumerator over Freshest CRL distribution points and issuers.
+ *
+ * @return enumerator over x509_cdp_t
+ */
+ enumerator_t* (*create_delta_crl_uri_enumerator)(crl_t *this);
+
+ /**
* Create an enumerator over all revoked certificates.
*
* The enumerator takes 3 pointer arguments:
diff --git a/src/libstrongswan/credentials/certificates/x509.h b/src/libstrongswan/credentials/certificates/x509.h
index 6e0a5002a..fec02dbad 100644
--- a/src/libstrongswan/credentials/certificates/x509.h
+++ b/src/libstrongswan/credentials/certificates/x509.h
@@ -24,10 +24,15 @@
#include <utils/enumerator.h>
#include <credentials/certificates/certificate.h>
-#define X509_NO_PATH_LEN_CONSTRAINT -1
+/* constraints are currently restricted to the range 0..127 */
+#define X509_NO_CONSTRAINT 255
typedef struct x509_t x509_t;
+typedef struct x509_cert_policy_t x509_cert_policy_t;
+typedef struct x509_policy_mapping_t x509_policy_mapping_t;
+typedef struct x509_cdp_t x509_cdp_t;
typedef enum x509_flag_t x509_flag_t;
+typedef enum x509_constraint_t x509_constraint_t;
/**
* X.509 certificate flags.
@@ -49,12 +54,55 @@ enum x509_flag_t {
X509_SELF_SIGNED = (1<<5),
/** cert has an ipAddrBlocks extension */
X509_IP_ADDR_BLOCKS = (1<<6),
+ /** cert has CRL sign key usage */
+ X509_CRL_SIGN = (1<<7),
};
/**
- * enum names for x509 flags
+ * Different numerical X.509 constraints.
*/
-extern enum_name_t *x509_flag_names;
+enum x509_constraint_t {
+ /** pathLenConstraint basicConstraints */
+ X509_PATH_LEN,
+ /** inhibitPolicyMapping policyConstraint */
+ X509_INHIBIT_POLICY_MAPPING,
+ /** requireExplicitPolicy policyConstraint */
+ X509_REQUIRE_EXPLICIT_POLICY,
+ /** inhibitAnyPolicy constraint */
+ X509_INHIBIT_ANY_POLICY,
+};
+
+/**
+ * X.509 certPolicy extension.
+ */
+struct x509_cert_policy_t {
+ /** OID of certPolicy */
+ chunk_t oid;
+ /** Certification Practice Statement URI qualifier */
+ char *cps_uri;
+ /** UserNotice Text qualifier */
+ char *unotice_text;
+};
+
+/**
+ * X.509 policyMapping extension
+ */
+struct x509_policy_mapping_t {
+ /** OID of issuerDomainPolicy */
+ chunk_t issuer;
+ /** OID of subjectDomainPolicy */
+ chunk_t subject;
+};
+
+/**
+ * X.509 CRL distributionPoint
+ */
+struct x509_cdp_t {
+ /** CDP URI, as string */
+ char *uri;
+ /** CRL issuer */
+ identification_t *issuer;
+};
/**
* X.509 certificate interface.
@@ -98,11 +146,12 @@ struct x509_t {
chunk_t (*get_authKeyIdentifier)(x509_t *this);
/**
- * Get an optional path length constraint.
+ * Get a numerical X.509 constraint.
*
- * @return pathLenConstraint, -1 if no constraint exists
+ * @param type type of constraint to get
+ * @return constraint, X509_NO_CONSTRAINT if none found
*/
- int (*get_pathLenConstraint)(x509_t *this);
+ u_int (*get_constraint)(x509_t *this, x509_constraint_t type);
/**
* Create an enumerator over all subjectAltNames.
@@ -112,9 +161,9 @@ struct x509_t {
enumerator_t* (*create_subjectAltName_enumerator)(x509_t *this);
/**
- * Create an enumerator over all CRL URIs.
+ * Create an enumerator over all CRL URIs and CRL Issuers.
*
- * @return enumerator over URIs as char*
+ * @return enumerator over x509_cdp_t
*/
enumerator_t* (*create_crl_uri_enumerator)(x509_t *this);
@@ -131,6 +180,30 @@ struct x509_t {
* @return enumerator over ipAddrBlocks as traffic_selector_t*
*/
enumerator_t* (*create_ipAddrBlock_enumerator)(x509_t *this);
+
+ /**
+ * Create an enumerator over name constraints.
+ *
+ * @param perm TRUE for permitted, FALSE for excluded subtrees
+ * @return enumerator over subtrees as identification_t
+ */
+ enumerator_t* (*create_name_constraint_enumerator)(x509_t *this, bool perm);
+
+ /**
+ * Create an enumerator over certificate policies.
+ *
+ * @return enumerator over x509_cert_policy_t
+ */
+ enumerator_t* (*create_cert_policy_enumerator)(x509_t *this);
+
+ /**
+ * Create an enumerator over policy mappings.
+ *
+ * @return enumerator over x509_policy_mapping
+ */
+ enumerator_t* (*create_policy_mapping_enumerator)(x509_t *this);
+
+
};
#endif /** X509_H_ @}*/
diff --git a/src/libstrongswan/credentials/credential_manager.c b/src/libstrongswan/credentials/credential_manager.c
index 97e8d8887..27b97eab3 100644
--- a/src/libstrongswan/credentials/credential_manager.c
+++ b/src/libstrongswan/credentials/credential_manager.c
@@ -452,8 +452,8 @@ static void cache_queue(private_credential_manager_t *this)
* check a certificate for its lifetime
*/
static bool check_certificate(private_credential_manager_t *this,
- certificate_t *subject, certificate_t *issuer,
- bool online, int pathlen, auth_cfg_t *auth)
+ certificate_t *subject, certificate_t *issuer, bool online,
+ int pathlen, bool trusted, auth_cfg_t *auth)
{
time_t not_before, not_after;
cert_validator_t *validator;
@@ -471,29 +471,12 @@ static bool check_certificate(private_credential_manager_t *this,
&not_before, FALSE, &not_after, FALSE);
return FALSE;
}
- if (issuer->get_type(issuer) == CERT_X509 &&
- subject->get_type(subject) == CERT_X509)
- {
- int pathlen_constraint;
- x509_t *x509;
-
- /* check path length constraint */
- x509 = (x509_t*)issuer;
- pathlen_constraint = x509->get_pathLenConstraint(x509);
- if (pathlen_constraint != X509_NO_PATH_LEN_CONSTRAINT &&
- pathlen > pathlen_constraint)
- {
- DBG1(DBG_CFG, "path length of %d violates constraint of %d",
- pathlen, pathlen_constraint);
- return FALSE;
- }
- }
enumerator = this->validators->create_enumerator(this->validators);
while (enumerator->enumerate(enumerator, &validator))
{
if (!validator->validate(validator, subject, issuer,
- online, pathlen, auth))
+ online, pathlen, trusted, auth))
{
enumerator->destroy(enumerator);
return FALSE;
@@ -551,6 +534,37 @@ static certificate_t *get_issuer_cert(private_credential_manager_t *this,
}
/**
+ * Get the strength of certificate, add it to auth
+ */
+static void get_key_strength(certificate_t *cert, auth_cfg_t *auth)
+{
+ uintptr_t strength;
+ public_key_t *key;
+ key_type_t type;
+
+ key = cert->get_public_key(cert);
+ if (key)
+ {
+ type = key->get_type(key);
+ strength = key->get_keysize(key);
+ DBG2(DBG_CFG, " certificate \"%Y\" key: %d bit %N",
+ cert->get_subject(cert), strength, key_type_names, type);
+ switch (type)
+ {
+ case KEY_RSA:
+ auth->add(auth, AUTH_RULE_RSA_STRENGTH, strength);
+ break;
+ case KEY_ECDSA:
+ auth->add(auth, AUTH_RULE_ECDSA_STRENGTH, strength);
+ break;
+ default:
+ break;
+ }
+ key->destroy(key);
+ }
+}
+
+/**
* try to verify the trust chain of subject, return TRUE if trusted
*/
static bool verify_trust_chain(private_credential_manager_t *this,
@@ -562,7 +576,9 @@ static bool verify_trust_chain(private_credential_manager_t *this,
int pathlen;
auth = auth_cfg_create();
+ get_key_strength(subject, auth);
current = subject->get_ref(subject);
+ auth->add(auth, AUTH_RULE_SUBJECT_CERT, current->get_ref(current));
for (pathlen = 0; pathlen <= MAX_TRUST_PATH_LEN; pathlen++)
{
@@ -607,13 +623,17 @@ static bool verify_trust_chain(private_credential_manager_t *this,
break;
}
}
- if (!check_certificate(this, current, issuer, online, pathlen,
- current == subject ? auth : NULL))
+ if (!check_certificate(this, current, issuer, online,
+ pathlen, trusted, auth))
{
trusted = FALSE;
issuer->destroy(issuer);
break;
}
+ if (issuer)
+ {
+ get_key_strength(issuer, auth);
+ }
current->destroy(current);
current = issuer;
if (trusted)
@@ -637,6 +657,14 @@ static bool verify_trust_chain(private_credential_manager_t *this,
}
/**
+ * List find match function for certificates
+ */
+static bool cert_equals(certificate_t *a, certificate_t *b)
+{
+ return a->equals(a, b);
+}
+
+/**
* enumerator for trusted certificates
*/
typedef struct {
@@ -656,6 +684,8 @@ typedef struct {
certificate_t *pretrusted;
/** currently enumerating auth config */
auth_cfg_t *auth;
+ /** list of failed candidates */
+ linked_list_t *failed;
} trusted_enumerator_t;
METHOD(enumerator_t, trusted_enumerate, bool,
@@ -683,11 +713,14 @@ METHOD(enumerator_t, trusted_enumerate, bool,
verify_trust_chain(this->this, this->pretrusted, this->auth,
TRUE, this->online))
{
- this->auth->add(this->auth, AUTH_RULE_SUBJECT_CERT,
- this->pretrusted->get_ref(this->pretrusted));
DBG1(DBG_CFG, " using trusted certificate \"%Y\"",
this->pretrusted->get_subject(this->pretrusted));
*cert = this->pretrusted;
+ if (!this->auth->get(this->auth, AUTH_RULE_SUBJECT_CERT))
+ { /* add cert to auth info, if not returned by trustchain */
+ this->auth->add(this->auth, AUTH_RULE_SUBJECT_CERT,
+ this->pretrusted->get_ref(this->pretrusted));
+ }
if (auth)
{
*auth = this->auth;
@@ -705,6 +738,12 @@ METHOD(enumerator_t, trusted_enumerate, bool,
continue;
}
+ if (this->failed->find_first(this->failed, (void*)cert_equals,
+ NULL, current) == SUCCESS)
+ { /* check each candidate only once */
+ continue;
+ }
+
DBG1(DBG_CFG, " using certificate \"%Y\"",
current->get_subject(current));
if (verify_trust_chain(this->this, current, this->auth, FALSE,
@@ -717,6 +756,7 @@ METHOD(enumerator_t, trusted_enumerate, bool,
}
return TRUE;
}
+ this->failed->insert_last(this->failed, current->get_ref(current));
}
return FALSE;
}
@@ -727,6 +767,7 @@ METHOD(enumerator_t, trusted_destroy, void,
DESTROY_IF(this->pretrusted);
DESTROY_IF(this->auth);
DESTROY_IF(this->candidates);
+ this->failed->destroy_offset(this->failed, offsetof(certificate_t, destroy));
free(this);
}
@@ -745,6 +786,7 @@ METHOD(credential_manager_t, create_trusted_enumerator, enumerator_t*,
.type = type,
.id = id,
.online = online,
+ .failed = linked_list_create(),
);
return &enumerator->public;
}
diff --git a/src/libstrongswan/credentials/sets/auth_cfg_wrapper.c b/src/libstrongswan/credentials/sets/auth_cfg_wrapper.c
index 5e8458616..225fabe31 100644
--- a/src/libstrongswan/credentials/sets/auth_cfg_wrapper.c
+++ b/src/libstrongswan/credentials/sets/auth_cfg_wrapper.c
@@ -132,7 +132,8 @@ static bool enumerate(wrapper_enumerator_t *this, certificate_t **cert)
}
}
else if (rule != AUTH_HELPER_SUBJECT_CERT &&
- rule != AUTH_HELPER_IM_CERT)
+ rule != AUTH_HELPER_IM_CERT &&
+ rule != AUTH_HELPER_REVOCATION_CERT)
{ /* handle only HELPER certificates */
continue;
}
diff --git a/src/libstrongswan/credentials/sets/mem_cred.c b/src/libstrongswan/credentials/sets/mem_cred.c
index c29a99f1f..e023e8443 100644
--- a/src/libstrongswan/credentials/sets/mem_cred.c
+++ b/src/libstrongswan/credentials/sets/mem_cred.c
@@ -1,4 +1,6 @@
/*
+ * Copyright (C) 2010 Tobias Brunner
+ * Hochschule fuer Technik Rapperwsil
* Copyright (C) 2010 Martin Willi
* Copyright (C) 2010 revosec AG
*
@@ -54,6 +56,11 @@ struct private_mem_cred_t {
* List of shared keys, as shared_entry_t
*/
linked_list_t *shared;
+
+ /**
+ * List of CDPs, as cdp_t
+ */
+ linked_list_t *cdps;
};
/**
@@ -144,21 +151,104 @@ static bool certificate_equals(certificate_t *item, certificate_t *cert)
return item->equals(item, cert);
}
+/**
+ * Add a certificate the the cache. Returns a reference to "cert" or a
+ * previously cached certificate that equals "cert".
+ */
+static certificate_t *add_cert_internal(private_mem_cred_t *this, bool trusted,
+ certificate_t *cert)
+{
+ certificate_t *cached;
+ this->lock->write_lock(this->lock);
+ if (this->untrusted->find_first(this->untrusted,
+ (linked_list_match_t)certificate_equals,
+ (void**)&cached, cert) == SUCCESS)
+ {
+ cert->destroy(cert);
+ cert = cached->get_ref(cached);
+ }
+ else
+ {
+ if (trusted)
+ {
+ this->trusted->insert_first(this->trusted, cert->get_ref(cert));
+ }
+ this->untrusted->insert_first(this->untrusted, cert->get_ref(cert));
+ }
+ this->lock->unlock(this->lock);
+ return cert;
+}
+
METHOD(mem_cred_t, add_cert, void,
private_mem_cred_t *this, bool trusted, certificate_t *cert)
{
+ certificate_t *cached = add_cert_internal(this, trusted, cert);
+ cached->destroy(cached);
+}
+
+METHOD(mem_cred_t, add_cert_ref, certificate_t*,
+ private_mem_cred_t *this, bool trusted, certificate_t *cert)
+{
+ return add_cert_internal(this, trusted, cert);
+}
+
+METHOD(mem_cred_t, add_crl, bool,
+ private_mem_cred_t *this, crl_t *crl)
+{
+ certificate_t *current, *cert = &crl->certificate;
+ enumerator_t *enumerator;
+ bool new = TRUE;
+
this->lock->write_lock(this->lock);
- if (this->untrusted->find_last(this->untrusted,
- (linked_list_match_t)certificate_equals, NULL, cert) != SUCCESS)
+ enumerator = this->untrusted->create_enumerator(this->untrusted);
+ while (enumerator->enumerate(enumerator, (void**)&current))
{
- if (trusted)
+ if (current->get_type(current) == CERT_X509_CRL)
{
- this->trusted->insert_last(this->trusted, cert->get_ref(cert));
+ bool found = FALSE;
+ crl_t *crl_c = (crl_t*)current;
+ chunk_t authkey = crl->get_authKeyIdentifier(crl);
+ chunk_t authkey_c = crl_c->get_authKeyIdentifier(crl_c);
+
+ /* compare authorityKeyIdentifiers if available */
+ if (chunk_equals(authkey, authkey_c))
+ {
+ found = TRUE;
+ }
+ else
+ {
+ identification_t *issuer = cert->get_issuer(cert);
+ identification_t *issuer_c = current->get_issuer(current);
+
+ /* otherwise compare issuer distinguished names */
+ if (issuer->equals(issuer, issuer_c))
+ {
+ found = TRUE;
+ }
+ }
+ if (found)
+ {
+ new = crl_is_newer(crl, crl_c);
+ if (new)
+ {
+ this->untrusted->remove_at(this->untrusted, enumerator);
+ }
+ else
+ {
+ cert->destroy(cert);
+ }
+ break;
+ }
}
- this->untrusted->insert_last(this->untrusted, cert->get_ref(cert));
}
- cert->destroy(cert);
+ enumerator->destroy(enumerator);
+
+ if (new)
+ {
+ this->untrusted->insert_first(this->untrusted, cert);
+ }
this->lock->unlock(this->lock);
+ return new;
}
/**
@@ -218,7 +308,7 @@ METHOD(mem_cred_t, add_key, void,
private_mem_cred_t *this, private_key_t *key)
{
this->lock->write_lock(this->lock);
- this->keys->insert_last(this->keys, key);
+ this->keys->insert_first(this->keys, key);
this->lock->unlock(this->lock);
}
@@ -342,32 +432,137 @@ METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
(void*)shared_filter, data, (void*)shared_data_destroy);
}
-METHOD(mem_cred_t, add_shared, void,
- private_mem_cred_t *this, shared_key_t *shared, ...)
+METHOD(mem_cred_t, add_shared_list, void,
+ private_mem_cred_t *this, shared_key_t *shared, linked_list_t* owners)
{
shared_entry_t *entry;
- identification_t *id;
- va_list args;
INIT(entry,
.shared = shared,
- .owners = linked_list_create(),
+ .owners = owners,
);
+ this->lock->write_lock(this->lock);
+ this->shared->insert_first(this->shared, entry);
+ this->lock->unlock(this->lock);
+}
+
+METHOD(mem_cred_t, add_shared, void,
+ private_mem_cred_t *this, shared_key_t *shared, ...)
+{
+ identification_t *id;
+ linked_list_t *owners = linked_list_create();
+ va_list args;
+
va_start(args, shared);
do
{
id = va_arg(args, identification_t*);
if (id)
{
- entry->owners->insert_last(entry->owners, id);
+ owners->insert_first(owners, id);
}
}
while (id);
va_end(args);
+ add_shared_list(this, shared, owners);
+}
+
+/**
+ * Certificate distribution point
+ */
+typedef struct {
+ certificate_type_t type;
+ identification_t *id;
+ char *uri;
+} cdp_t;
+
+/**
+ * Destroy a CDP entry
+ */
+static void cdp_destroy(cdp_t *this)
+{
+ this->id->destroy(this->id);
+ free(this->uri);
+ free(this);
+}
+
+METHOD(mem_cred_t, add_cdp, void,
+ private_mem_cred_t *this, certificate_type_t type,
+ identification_t *id, char *uri)
+{
+ cdp_t *cdp;
+
+ INIT(cdp,
+ .type = type,
+ .id = id->clone(id),
+ .uri = strdup(uri),
+ );
+ this->lock->write_lock(this->lock);
+ this->cdps->insert_last(this->cdps, cdp);
+ this->lock->unlock(this->lock);
+}
+
+/**
+ * CDP enumerator data
+ */
+typedef struct {
+ certificate_type_t type;
+ identification_t *id;
+ rwlock_t *lock;
+} cdp_data_t;
+
+/**
+ * Clean up CDP enumerator data
+ */
+static void cdp_data_destroy(cdp_data_t *data)
+{
+ data->lock->unlock(data->lock);
+ free(data);
+}
+
+/**
+ * CDP enumerator filter
+ */
+static bool cdp_filter(cdp_data_t *data, cdp_t **cdp, char **uri)
+{
+ if (data->type != CERT_ANY && data->type != (*cdp)->type)
+ {
+ return FALSE;
+ }
+ if (data->id && !(*cdp)->id->matches((*cdp)->id, data->id))
+ {
+ return FALSE;
+ }
+ *uri = (*cdp)->uri;
+ return TRUE;
+}
+
+METHOD(credential_set_t, create_cdp_enumerator, enumerator_t*,
+ private_mem_cred_t *this, certificate_type_t type, identification_t *id)
+{
+ cdp_data_t *data;
+
+ INIT(data,
+ .type = type,
+ .id = id,
+ .lock = this->lock,
+ );
+ this->lock->read_lock(this->lock);
+ return enumerator_create_filter(this->cdps->create_enumerator(this->cdps),
+ (void*)cdp_filter, data, (void*)cdp_data_destroy);
+
+}
+
+METHOD(mem_cred_t, clear_secrets, void,
+ private_mem_cred_t *this)
+{
this->lock->write_lock(this->lock);
- this->shared->insert_last(this->shared, entry);
+ this->keys->destroy_offset(this->keys, offsetof(private_key_t, destroy));
+ this->shared->destroy_function(this->shared, (void*)shared_entry_destroy);
+ this->keys = linked_list_create();
+ this->shared = linked_list_create();
this->lock->unlock(this->lock);
}
@@ -379,13 +574,13 @@ METHOD(mem_cred_t, clear_, void,
offsetof(certificate_t, destroy));
this->untrusted->destroy_offset(this->untrusted,
offsetof(certificate_t, destroy));
- this->keys->destroy_offset(this->keys, offsetof(private_key_t, destroy));
- this->shared->destroy_function(this->shared, (void*)shared_entry_destroy);
+ this->cdps->destroy_function(this->cdps, (void*)cdp_destroy);
this->trusted = linked_list_create();
this->untrusted = linked_list_create();
- this->keys = linked_list_create();
- this->shared = linked_list_create();
+ this->cdps = linked_list_create();
this->lock->unlock(this->lock);
+
+ clear_secrets(this);
}
METHOD(mem_cred_t, destroy, void,
@@ -396,6 +591,7 @@ METHOD(mem_cred_t, destroy, void,
this->untrusted->destroy(this->untrusted);
this->keys->destroy(this->keys);
this->shared->destroy(this->shared);
+ this->cdps->destroy(this->cdps);
this->lock->destroy(this->lock);
free(this);
}
@@ -413,19 +609,25 @@ mem_cred_t *mem_cred_create()
.create_shared_enumerator = _create_shared_enumerator,
.create_private_enumerator = _create_private_enumerator,
.create_cert_enumerator = _create_cert_enumerator,
- .create_cdp_enumerator = (void*)return_null,
+ .create_cdp_enumerator = _create_cdp_enumerator,
.cache_cert = (void*)nop,
},
.add_cert = _add_cert,
+ .add_cert_ref = _add_cert_ref,
+ .add_crl = _add_crl,
.add_key = _add_key,
.add_shared = _add_shared,
+ .add_shared_list = _add_shared_list,
+ .add_cdp = _add_cdp,
.clear = _clear_,
+ .clear_secrets = _clear_secrets,
.destroy = _destroy,
},
.trusted = linked_list_create(),
.untrusted = linked_list_create(),
.keys = linked_list_create(),
.shared = linked_list_create(),
+ .cdps = linked_list_create(),
.lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
);
diff --git a/src/libstrongswan/credentials/sets/mem_cred.h b/src/libstrongswan/credentials/sets/mem_cred.h
index b26e43d6c..eb46b065b 100644
--- a/src/libstrongswan/credentials/sets/mem_cred.h
+++ b/src/libstrongswan/credentials/sets/mem_cred.h
@@ -1,4 +1,6 @@
/*
+ * Copyright (C) 2010 Tobias Brunner
+ * Hochschule fuer Technik Rapperswil
* Copyright (C) 2010 Martin Willi
* Copyright (C) 2010 revosec AG
*
@@ -24,6 +26,8 @@
typedef struct mem_cred_t mem_cred_t;
#include <credentials/credential_set.h>
+#include <credentials/certificates/crl.h>
+#include <utils/linked_list.h>
/**
* Generic in-memory credential set.
@@ -44,6 +48,26 @@ struct mem_cred_t {
void (*add_cert)(mem_cred_t *this, bool trusted, certificate_t *cert);
/**
+ * Add a certificate to the credential set, returning a reference to it or
+ * to a cached duplicate.
+ *
+ * @param trusted TRUE to serve certificate as trusted
+ * @param cert certificate, reference gets owned by set
+ * @return reference to cert or a previously cached duplicate
+ */
+ certificate_t *(*add_cert_ref)(mem_cred_t *this, bool trusted,
+ certificate_t *cert);
+
+ /**
+ * Add an X.509 CRL to the credential set.
+ *
+ * @param crl CRL, gets owned by set
+ * @return TRUE, if the CRL is newer than an existing one (or
+ * new at all)
+ */
+ bool (*add_crl)(mem_cred_t *this, crl_t *crl);
+
+ /**
* Add a private key to the credential set.
*
* @param key key, reference gets owned by set
@@ -54,16 +78,40 @@ struct mem_cred_t {
* Add a shared key to the credential set.
*
* @param shared shared key to add, gets owned by set
- * @param ... NULL terminated list of owners identification_t*
+ * @param ... NULL terminated list of owners (identification_t*)
*/
void (*add_shared)(mem_cred_t *this, shared_key_t *shared, ...);
/**
+ * Add a shared key to the credential set.
+ *
+ * @param shared shared key to add, gets owned by set
+ * @param owners list of owners (identification_t*), gets owned
+ */
+ void (*add_shared_list)(mem_cred_t *this, shared_key_t *shared,
+ linked_list_t *owners);
+ /**
+ * Add a certificate distribution point to the set.
+ *
+ * @param type type of the certificate
+ * @param id certificate ID CDP has a cert for, gets cloned
+ * @param uri CDP URI, gets strduped
+ */
+ void (*add_cdp)(mem_cred_t *this, certificate_type_t type,
+ identification_t *id, char *uri);
+
+ /**
* Clear all credentials from the credential set.
*/
void (*clear)(mem_cred_t *this);
/**
+ * Clear the secrets (private and shared keys, not the certificates) from
+ * the credential set.
+ */
+ void (*clear_secrets)(mem_cred_t *this);
+
+ /**
* Destroy a mem_cred_t.
*/
void (*destroy)(mem_cred_t *this);
diff --git a/src/libstrongswan/crypto/crypto_factory.c b/src/libstrongswan/crypto/crypto_factory.c
index f2f01987d..2d13896d6 100644
--- a/src/libstrongswan/crypto/crypto_factory.c
+++ b/src/libstrongswan/crypto/crypto_factory.c
@@ -20,13 +20,29 @@
#include <utils/linked_list.h>
#include <crypto/crypto_tester.h>
+const char *default_plugin_name = "default";
+
typedef struct entry_t entry_t;
+
struct entry_t {
- /* algorithm */
+ /**
+ * algorithm
+ */
u_int algo;
- /* benchmarked speed */
+
+ /**
+ * plugin that registered this algorithm
+ */
+ const char *plugin_name;
+
+ /**
+ * benchmarked speed
+ */
u_int speed;
- /* constructor */
+
+ /**
+ * constructor
+ */
union {
crypter_constructor_t create_crypter;
aead_constructor_t create_aead;
@@ -128,7 +144,8 @@ METHOD(crypto_factory_t, create_crypter, crypter_t*,
{
if (this->test_on_create &&
!this->tester->test_crypter(this->tester, algo, key_size,
- entry->create_crypter, NULL))
+ entry->create_crypter, NULL,
+ default_plugin_name))
{
continue;
}
@@ -160,7 +177,8 @@ METHOD(crypto_factory_t, create_aead, aead_t*,
{
if (this->test_on_create &&
!this->tester->test_aead(this->tester, algo, key_size,
- entry->create_aead, NULL))
+ entry->create_aead, NULL,
+ default_plugin_name))
{
continue;
}
@@ -191,7 +209,8 @@ METHOD(crypto_factory_t, create_signer, signer_t*,
{
if (this->test_on_create &&
!this->tester->test_signer(this->tester, algo,
- entry->create_signer, NULL))
+ entry->create_signer, NULL,
+ default_plugin_name))
{
continue;
}
@@ -223,7 +242,8 @@ METHOD(crypto_factory_t, create_hasher, hasher_t*,
{
if (this->test_on_create && algo != HASH_PREFERRED &&
!this->tester->test_hasher(this->tester, algo,
- entry->create_hasher, NULL))
+ entry->create_hasher, NULL,
+ default_plugin_name))
{
continue;
}
@@ -254,7 +274,8 @@ METHOD(crypto_factory_t, create_prf, prf_t*,
{
if (this->test_on_create &&
!this->tester->test_prf(this->tester, algo,
- entry->create_prf, NULL))
+ entry->create_prf, NULL,
+ default_plugin_name))
{
continue;
}
@@ -286,7 +307,8 @@ METHOD(crypto_factory_t, create_rng, rng_t*,
{
if (this->test_on_create &&
!this->tester->test_rng(this->tester, quality,
- entry->create_rng, NULL))
+ entry->create_rng, NULL,
+ default_plugin_name))
{
continue;
}
@@ -350,7 +372,8 @@ METHOD(crypto_factory_t, create_dh, diffie_hellman_t*,
* Insert an algorithm entry to a list
*/
static void add_entry(private_crypto_factory_t *this, linked_list_t *list,
- int algo, u_int speed, void *create)
+ int algo, const char *plugin_name,
+ u_int speed, void *create)
{
entry_t *entry, *current;
linked_list_t *tmp;
@@ -358,6 +381,7 @@ static void add_entry(private_crypto_factory_t *this, linked_list_t *list,
INIT(entry,
.algo = algo,
+ .plugin_name = plugin_name,
.speed = speed,
);
entry->create = create;
@@ -391,16 +415,16 @@ static void add_entry(private_crypto_factory_t *this, linked_list_t *list,
}
METHOD(crypto_factory_t, add_crypter, void,
- private_crypto_factory_t *this, encryption_algorithm_t algo,
- crypter_constructor_t create)
+ private_crypto_factory_t *this, encryption_algorithm_t algo,
+ const char *plugin_name, crypter_constructor_t create)
{
u_int speed = 0;
if (!this->test_on_add ||
this->tester->test_crypter(this->tester, algo, 0, create,
- this->bench ? &speed : NULL))
+ this->bench ? &speed : NULL, plugin_name))
{
- add_entry(this, this->crypters, algo, speed, create);
+ add_entry(this, this->crypters, algo, plugin_name, speed, create);
}
}
@@ -425,16 +449,16 @@ METHOD(crypto_factory_t, remove_crypter, void,
}
METHOD(crypto_factory_t, add_aead, void,
- private_crypto_factory_t *this, encryption_algorithm_t algo,
- aead_constructor_t create)
+ private_crypto_factory_t *this, encryption_algorithm_t algo,
+ const char *plugin_name, aead_constructor_t create)
{
u_int speed = 0;
if (!this->test_on_add ||
this->tester->test_aead(this->tester, algo, 0, create,
- this->bench ? &speed : NULL))
+ this->bench ? &speed : NULL, plugin_name))
{
- add_entry(this, this->aeads, algo, speed, create);
+ add_entry(this, this->aeads, algo, plugin_name, speed, create);
}
}
@@ -459,16 +483,16 @@ METHOD(crypto_factory_t, remove_aead, void,
}
METHOD(crypto_factory_t, add_signer, void,
- private_crypto_factory_t *this, integrity_algorithm_t algo,
- signer_constructor_t create)
+ private_crypto_factory_t *this, integrity_algorithm_t algo,
+ const char *plugin_name, signer_constructor_t create)
{
u_int speed = 0;
if (!this->test_on_add ||
this->tester->test_signer(this->tester, algo, create,
- this->bench ? &speed : NULL))
+ this->bench ? &speed : NULL, plugin_name))
{
- add_entry(this, this->signers, algo, speed, create);
+ add_entry(this, this->signers, algo, plugin_name, speed, create);
}
}
@@ -493,16 +517,16 @@ METHOD(crypto_factory_t, remove_signer, void,
}
METHOD(crypto_factory_t, add_hasher, void,
- private_crypto_factory_t *this, hash_algorithm_t algo,
- hasher_constructor_t create)
+ private_crypto_factory_t *this, hash_algorithm_t algo,
+ const char *plugin_name, hasher_constructor_t create)
{
u_int speed = 0;
if (!this->test_on_add ||
this->tester->test_hasher(this->tester, algo, create,
- this->bench ? &speed : NULL))
+ this->bench ? &speed : NULL, plugin_name))
{
- add_entry(this, this->hashers, algo, speed, create);
+ add_entry(this, this->hashers, algo, plugin_name, speed, create);
}
}
@@ -527,16 +551,16 @@ METHOD(crypto_factory_t, remove_hasher, void,
}
METHOD(crypto_factory_t, add_prf, void,
- private_crypto_factory_t *this, pseudo_random_function_t algo,
- prf_constructor_t create)
+ private_crypto_factory_t *this, pseudo_random_function_t algo,
+ const char *plugin_name, prf_constructor_t create)
{
u_int speed = 0;
if (!this->test_on_add ||
this->tester->test_prf(this->tester, algo, create,
- this->bench ? &speed : NULL))
+ this->bench ? &speed : NULL, plugin_name))
{
- add_entry(this, this->prfs, algo, speed, create);
+ add_entry(this, this->prfs, algo, plugin_name, speed, create);
}
}
@@ -562,15 +586,15 @@ METHOD(crypto_factory_t, remove_prf, void,
METHOD(crypto_factory_t, add_rng, void,
private_crypto_factory_t *this, rng_quality_t quality,
- rng_constructor_t create)
+ const char *plugin_name, rng_constructor_t create)
{
u_int speed = 0;
if (!this->test_on_add ||
this->tester->test_rng(this->tester, quality, create,
- this->bench ? &speed : NULL))
+ this->bench ? &speed : NULL, plugin_name))
{
- add_entry(this, this->rngs, quality, speed, create);
+ add_entry(this, this->rngs, quality, plugin_name, speed, create);
}
}
@@ -595,10 +619,10 @@ METHOD(crypto_factory_t, remove_rng, void,
}
METHOD(crypto_factory_t, add_dh, void,
- private_crypto_factory_t *this, diffie_hellman_group_t group,
- dh_constructor_t create)
+ private_crypto_factory_t *this, diffie_hellman_group_t group,
+ const char *plugin_name, dh_constructor_t create)
{
- add_entry(this, this->dhs, group, 0, create);
+ add_entry(this, this->dhs, group, plugin_name, 0, create);
}
METHOD(crypto_factory_t, remove_dh, void,
@@ -660,9 +684,11 @@ static enumerator_t *create_enumerator(private_crypto_factory_t *this,
/**
* Filter function to enumerate algorithm, not entry
*/
-static bool crypter_filter(void *n, entry_t **entry, encryption_algorithm_t *algo)
+static bool crypter_filter(void *n, entry_t **entry, encryption_algorithm_t *algo,
+ void *i2, const char **plugin_name)
{
*algo = (*entry)->algo;
+ *plugin_name = (*entry)->plugin_name;
return TRUE;
}
@@ -681,9 +707,11 @@ METHOD(crypto_factory_t, create_aead_enumerator, enumerator_t*,
/**
* Filter function to enumerate algorithm, not entry
*/
-static bool signer_filter(void *n, entry_t **entry, integrity_algorithm_t *algo)
+static bool signer_filter(void *n, entry_t **entry, integrity_algorithm_t *algo,
+ void *i2, const char **plugin_name)
{
*algo = (*entry)->algo;
+ *plugin_name = (*entry)->plugin_name;
return TRUE;
}
@@ -696,9 +724,11 @@ METHOD(crypto_factory_t, create_signer_enumerator, enumerator_t*,
/**
* Filter function to enumerate algorithm, not entry
*/
-static bool hasher_filter(void *n, entry_t **entry, hash_algorithm_t *algo)
+static bool hasher_filter(void *n, entry_t **entry, hash_algorithm_t *algo,
+ void *i2, const char **plugin_name)
{
*algo = (*entry)->algo;
+ *plugin_name = (*entry)->plugin_name;
return TRUE;
}
@@ -711,9 +741,11 @@ METHOD(crypto_factory_t, create_hasher_enumerator, enumerator_t*,
/**
* Filter function to enumerate algorithm, not entry
*/
-static bool prf_filter(void *n, entry_t **entry, pseudo_random_function_t *algo)
+static bool prf_filter(void *n, entry_t **entry, pseudo_random_function_t *algo,
+ void *i2, const char **plugin_name)
{
*algo = (*entry)->algo;
+ *plugin_name = (*entry)->plugin_name;
return TRUE;
}
@@ -726,9 +758,11 @@ METHOD(crypto_factory_t, create_prf_enumerator, enumerator_t*,
/**
* Filter function to enumerate algorithm, not entry
*/
-static bool dh_filter(void *n, entry_t **entry, diffie_hellman_group_t *group)
+static bool dh_filter(void *n, entry_t **entry, diffie_hellman_group_t *group,
+ void *i2, const char **plugin_name)
{
*group = (*entry)->algo;
+ *plugin_name = (*entry)->plugin_name;
return TRUE;
}
@@ -738,6 +772,22 @@ METHOD(crypto_factory_t, create_dh_enumerator, enumerator_t*,
return create_enumerator(this, this->dhs, dh_filter);
}
+/**
+ * Filter function to enumerate algorithm, not entry
+ */
+static bool rng_filter(void *n, entry_t **entry, rng_quality_t *quality,
+ void *i2, const char **plugin_name)
+{
+ *quality = (*entry)->algo;
+ *plugin_name = (*entry)->plugin_name;
+ return TRUE;
+}
+
+METHOD(crypto_factory_t, create_rng_enumerator, enumerator_t*,
+ private_crypto_factory_t *this)
+{
+ return create_enumerator(this, this->rngs, rng_filter);
+}
METHOD(crypto_factory_t, add_test_vector, void,
private_crypto_factory_t *this, transform_type_t type, void *vector)
{
@@ -812,6 +862,7 @@ crypto_factory_t *crypto_factory_create()
.create_hasher_enumerator = _create_hasher_enumerator,
.create_prf_enumerator = _create_prf_enumerator,
.create_dh_enumerator = _create_dh_enumerator,
+ .create_rng_enumerator = _create_rng_enumerator,
.add_test_vector = _add_test_vector,
.destroy = _destroy,
},
diff --git a/src/libstrongswan/crypto/crypto_factory.h b/src/libstrongswan/crypto/crypto_factory.h
index ff06eda7b..8e5db6355 100644
--- a/src/libstrongswan/crypto/crypto_factory.h
+++ b/src/libstrongswan/crypto/crypto_factory.h
@@ -33,6 +33,8 @@ typedef struct crypto_factory_t crypto_factory_t;
#include <crypto/diffie_hellman.h>
#include <crypto/transform.h>
+#define CRYPTO_MAX_ALG_LINE 120 /* characters */
+
/**
* Constructor function for crypters
*/
@@ -144,11 +146,12 @@ struct crypto_factory_t {
* Register a crypter constructor.
*
* @param algo algorithm to constructor
+ * @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
* @return
*/
void (*add_crypter)(crypto_factory_t *this, encryption_algorithm_t algo,
- crypter_constructor_t create);
+ const char *plugin_name, crypter_constructor_t create);
/**
* Unregister a crypter constructor.
@@ -168,21 +171,23 @@ struct crypto_factory_t {
* Register a aead constructor.
*
* @param algo algorithm to constructor
+ * @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
* @return
*/
void (*add_aead)(crypto_factory_t *this, encryption_algorithm_t algo,
- aead_constructor_t create);
+ const char *plugin_name, aead_constructor_t create);
/**
* Register a signer constructor.
*
* @param algo algorithm to constructor
+ * @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
* @return
*/
void (*add_signer)(crypto_factory_t *this, integrity_algorithm_t algo,
- signer_constructor_t create);
+ const char *plugin_name, signer_constructor_t create);
/**
* Unregister a signer constructor.
@@ -198,11 +203,12 @@ struct crypto_factory_t {
* create_hasher(HASH_PREFERRED).
*
* @param algo algorithm to constructor
+ * @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
* @return
*/
void (*add_hasher)(crypto_factory_t *this, hash_algorithm_t algo,
- hasher_constructor_t create);
+ const char *plugin_name, hasher_constructor_t create);
/**
* Unregister a hasher constructor.
@@ -215,11 +221,12 @@ struct crypto_factory_t {
* Register a prf constructor.
*
* @param algo algorithm to constructor
+ * @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
* @return
*/
void (*add_prf)(crypto_factory_t *this, pseudo_random_function_t algo,
- prf_constructor_t create);
+ const char *plugin_name, prf_constructor_t create);
/**
* Unregister a prf constructor.
@@ -232,9 +239,11 @@ struct crypto_factory_t {
* Register a source of randomness.
*
* @param quality quality of randomness this RNG serves
+ * @param plugin_name plugin that registered this algorithm
* @param create constructor function for such a quality
*/
- void (*add_rng)(crypto_factory_t *this, rng_quality_t quality, rng_constructor_t create);
+ void (*add_rng)(crypto_factory_t *this, rng_quality_t quality,
+ const char *plugin_name, rng_constructor_t create);
/**
* Unregister a source of randomness.
@@ -247,11 +256,12 @@ struct crypto_factory_t {
* Register a diffie hellman constructor.
*
* @param group dh group to constructor
+ * @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
* @return
*/
void (*add_dh)(crypto_factory_t *this, diffie_hellman_group_t group,
- dh_constructor_t create);
+ const char *plugin_name, dh_constructor_t create);
/**
* Unregister a diffie hellman constructor.
@@ -303,6 +313,13 @@ struct crypto_factory_t {
enumerator_t* (*create_dh_enumerator)(crypto_factory_t *this);
/**
+ * Create an enumerator over all registered random generators.
+ *
+ * @return enumerator over rng_quality_t
+ */
+ enumerator_t* (*create_rng_enumerator)(crypto_factory_t *this);
+
+ /**
* Add a test vector to the crypto factory.
*
* @param type type of the test vector
diff --git a/src/libstrongswan/crypto/crypto_tester.c b/src/libstrongswan/crypto/crypto_tester.c
index d17485ff2..276f4329a 100644
--- a/src/libstrongswan/crypto/crypto_tester.c
+++ b/src/libstrongswan/crypto/crypto_tester.c
@@ -165,7 +165,7 @@ static u_int bench_crypter(private_crypto_tester_t *this,
METHOD(crypto_tester_t, test_crypter, bool,
private_crypto_tester_t *this, encryption_algorithm_t alg, size_t key_size,
- crypter_constructor_t create, u_int *speed)
+ crypter_constructor_t create, u_int *speed, const char *plugin_name)
{
enumerator_t *enumerator;
crypter_test_vector_t *vector;
@@ -188,7 +188,11 @@ METHOD(crypto_tester_t, test_crypter, bool,
}
crypter = create(alg, vector->key_size);
if (!crypter)
- { /* key size not supported... */
+ {
+ DBG1(DBG_LIB, "%N[%s]: %u bit key size not supported",
+ encryption_algorithm_names, alg, plugin_name,
+ BITS_PER_BYTE * vector->key_size);
+ failed = TRUE;
continue;
}
@@ -231,31 +235,40 @@ METHOD(crypto_tester_t, test_crypter, bool,
crypter->destroy(crypter);
if (failed)
{
- DBG1(DBG_LIB, "disabled %N: %s test vector failed",
- encryption_algorithm_names, alg, get_name(vector));
+ DBG1(DBG_LIB, "disabled %N[%s]: %s test vector failed",
+ encryption_algorithm_names, alg, plugin_name, get_name(vector));
break;
}
}
enumerator->destroy(enumerator);
if (!tested)
{
- DBG1(DBG_LIB, "%s %N: no test vectors found",
- this->required ? "disabled" : "enabled ",
- encryption_algorithm_names, alg);
- return !this->required;
+ if (failed)
+ {
+ DBG1(DBG_LIB,"disable %N[%s]: no key size supported",
+ encryption_algorithm_names, alg, plugin_name);
+ return FALSE;
+ }
+ else
+ {
+ DBG1(DBG_LIB, "%s %N[%s]: no test vectors found",
+ this->required ? "disabled" : "enabled ",
+ encryption_algorithm_names, alg, plugin_name);
+ return !this->required;
+ }
}
if (!failed)
{
if (speed)
{
*speed = bench_crypter(this, alg, create);
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors, %d points",
- encryption_algorithm_names, alg, tested, *speed);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors, %d points",
+ encryption_algorithm_names, alg, tested, plugin_name, *speed);
}
else
{
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors",
- encryption_algorithm_names, alg, tested);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors",
+ encryption_algorithm_names, alg, plugin_name, tested);
}
}
return !failed;
@@ -311,7 +324,7 @@ static u_int bench_aead(private_crypto_tester_t *this,
METHOD(crypto_tester_t, test_aead, bool,
private_crypto_tester_t *this, encryption_algorithm_t alg, size_t key_size,
- aead_constructor_t create, u_int *speed)
+ aead_constructor_t create, u_int *speed, const char *plugin_name)
{
enumerator_t *enumerator;
aead_test_vector_t *vector;
@@ -335,7 +348,11 @@ METHOD(crypto_tester_t, test_aead, bool,
}
aead = create(alg, vector->key_size);
if (!aead)
- { /* key size not supported... */
+ {
+ DBG1(DBG_LIB, "%N[%s]: %u bit key size not supported",
+ encryption_algorithm_names, alg, plugin_name,
+ BITS_PER_BYTE * vector->key_size);
+ failed = TRUE;
continue;
}
@@ -388,31 +405,40 @@ METHOD(crypto_tester_t, test_aead, bool,
aead->destroy(aead);
if (failed)
{
- DBG1(DBG_LIB, "disabled %N: %s test vector failed",
- encryption_algorithm_names, alg, get_name(vector));
+ DBG1(DBG_LIB, "disabled %N[%s]: %s test vector failed",
+ encryption_algorithm_names, alg, plugin_name, get_name(vector));
break;
}
}
enumerator->destroy(enumerator);
if (!tested)
{
- DBG1(DBG_LIB, "%s %N: no test vectors found",
- this->required ? "disabled" : "enabled ",
- encryption_algorithm_names, alg);
- return !this->required;
+ if (failed)
+ {
+ DBG1(DBG_LIB,"disable %N[%s]: no key size supported",
+ encryption_algorithm_names, alg, plugin_name);
+ return FALSE;
+ }
+ else
+ {
+ DBG1(DBG_LIB, "%s %N[%s]: no test vectors found",
+ this->required ? "disabled" : "enabled ",
+ encryption_algorithm_names, alg, plugin_name);
+ return !this->required;
+ }
}
if (!failed)
{
if (speed)
{
*speed = bench_aead(this, alg, create);
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors, %d points",
- encryption_algorithm_names, alg, tested, *speed);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors, %d points",
+ encryption_algorithm_names, alg, plugin_name, tested, *speed);
}
else
{
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors",
- encryption_algorithm_names, alg, tested);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors",
+ encryption_algorithm_names, alg, plugin_name, tested);
}
}
return !failed;
@@ -460,7 +486,7 @@ static u_int bench_signer(private_crypto_tester_t *this,
METHOD(crypto_tester_t, test_signer, bool,
private_crypto_tester_t *this, integrity_algorithm_t alg,
- signer_constructor_t create, u_int *speed)
+ signer_constructor_t create, u_int *speed, const char *plugin_name)
{
enumerator_t *enumerator;
signer_test_vector_t *vector;
@@ -482,8 +508,8 @@ METHOD(crypto_tester_t, test_signer, bool,
signer = create(alg);
if (!signer)
{
- DBG1(DBG_LIB, "disabled %N: creating instance failed",
- integrity_algorithm_names, alg);
+ DBG1(DBG_LIB, "disabled %N[%s]: creating instance failed",
+ integrity_algorithm_names, alg, plugin_name);
failed = TRUE;
break;
}
@@ -538,17 +564,17 @@ METHOD(crypto_tester_t, test_signer, bool,
signer->destroy(signer);
if (failed)
{
- DBG1(DBG_LIB, "disabled %N: %s test vector failed",
- integrity_algorithm_names, alg, get_name(vector));
+ DBG1(DBG_LIB, "disabled %N[%s]: %s test vector failed",
+ integrity_algorithm_names, alg, plugin_name, get_name(vector));
break;
}
}
enumerator->destroy(enumerator);
if (!tested)
{
- DBG1(DBG_LIB, "%s %N: no test vectors found",
+ DBG1(DBG_LIB, "%s %N[%s]: no test vectors found",
this->required ? "disabled" : "enabled ",
- integrity_algorithm_names, alg);
+ integrity_algorithm_names, alg, plugin_name);
return !this->required;
}
if (!failed)
@@ -556,13 +582,13 @@ METHOD(crypto_tester_t, test_signer, bool,
if (speed)
{
*speed = bench_signer(this, alg, create);
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors, %d points",
- integrity_algorithm_names, alg, tested, *speed);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors, %d points",
+ integrity_algorithm_names, alg, plugin_name, tested, *speed);
}
else
{
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors",
- integrity_algorithm_names, alg, tested);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors",
+ integrity_algorithm_names, alg, plugin_name, tested);
}
}
return !failed;
@@ -604,7 +630,7 @@ static u_int bench_hasher(private_crypto_tester_t *this,
METHOD(crypto_tester_t, test_hasher, bool,
private_crypto_tester_t *this, hash_algorithm_t alg,
- hasher_constructor_t create, u_int *speed)
+ hasher_constructor_t create, u_int *speed, const char *plugin_name)
{
enumerator_t *enumerator;
hasher_test_vector_t *vector;
@@ -626,8 +652,8 @@ METHOD(crypto_tester_t, test_hasher, bool,
hasher = create(alg);
if (!hasher)
{
- DBG1(DBG_LIB, "disabled %N: creating instance failed",
- hash_algorithm_names, alg);
+ DBG1(DBG_LIB, "disabled %N[%s]: creating instance failed",
+ hash_algorithm_names, alg, plugin_name);
failed = TRUE;
break;
}
@@ -669,17 +695,17 @@ METHOD(crypto_tester_t, test_hasher, bool,
hasher->destroy(hasher);
if (failed)
{
- DBG1(DBG_LIB, "disabled %N: %s test vector failed",
- hash_algorithm_names, alg, get_name(vector));
+ DBG1(DBG_LIB, "disabled %N[%s]: %s test vector failed",
+ hash_algorithm_names, alg, plugin_name, get_name(vector));
break;
}
}
enumerator->destroy(enumerator);
if (!tested)
{
- DBG1(DBG_LIB, "%s %N: no test vectors found",
+ DBG1(DBG_LIB, "%s %N[%s]: no test vectors found",
this->required ? "disabled" : "enabled ",
- hash_algorithm_names, alg);
+ hash_algorithm_names, alg, plugin_name);
return !this->required;
}
if (!failed)
@@ -687,13 +713,13 @@ METHOD(crypto_tester_t, test_hasher, bool,
if (speed)
{
*speed = bench_hasher(this, alg, create);
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors, %d points",
- hash_algorithm_names, alg, tested, *speed);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors, %d points",
+ hash_algorithm_names, alg, plugin_name, tested, *speed);
}
else
{
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors",
- hash_algorithm_names, alg, tested);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors",
+ hash_algorithm_names, alg, plugin_name, tested);
}
}
return !failed;
@@ -735,7 +761,7 @@ static u_int bench_prf(private_crypto_tester_t *this,
METHOD(crypto_tester_t, test_prf, bool,
private_crypto_tester_t *this, pseudo_random_function_t alg,
- prf_constructor_t create, u_int *speed)
+ prf_constructor_t create, u_int *speed, const char *plugin_name)
{
enumerator_t *enumerator;
prf_test_vector_t *vector;
@@ -757,8 +783,8 @@ METHOD(crypto_tester_t, test_prf, bool,
prf = create(alg);
if (!prf)
{
- DBG1(DBG_LIB, "disabled %N: creating instance failed",
- pseudo_random_function_names, alg);
+ DBG1(DBG_LIB, "disabled %N[%s]: creating instance failed",
+ pseudo_random_function_names, alg, plugin_name);
failed = TRUE;
break;
}
@@ -811,17 +837,17 @@ METHOD(crypto_tester_t, test_prf, bool,
prf->destroy(prf);
if (failed)
{
- DBG1(DBG_LIB, "disabled %N: %s test vector failed",
- pseudo_random_function_names, alg, get_name(vector));
+ DBG1(DBG_LIB, "disabled %N[%s]: %s test vector failed",
+ pseudo_random_function_names, alg, plugin_name, get_name(vector));
break;
}
}
enumerator->destroy(enumerator);
if (!tested)
{
- DBG1(DBG_LIB, "%s %N: no test vectors found",
+ DBG1(DBG_LIB, "%s %N[%s]: no test vectors found",
this->required ? "disabled" : "enabled ",
- pseudo_random_function_names, alg);
+ pseudo_random_function_names, alg, plugin_name);
return !this->required;
}
if (!failed)
@@ -829,13 +855,13 @@ METHOD(crypto_tester_t, test_prf, bool,
if (speed)
{
*speed = bench_prf(this, alg, create);
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors, %d points",
- pseudo_random_function_names, alg, tested, *speed);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors, %d points",
+ pseudo_random_function_names, alg, plugin_name, tested, *speed);
}
else
{
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors",
- pseudo_random_function_names, alg, tested);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors",
+ pseudo_random_function_names, alg, plugin_name, tested);
}
}
return !failed;
@@ -874,7 +900,7 @@ static u_int bench_rng(private_crypto_tester_t *this,
METHOD(crypto_tester_t, test_rng, bool,
private_crypto_tester_t *this, rng_quality_t quality,
- rng_constructor_t create, u_int *speed)
+ rng_constructor_t create, u_int *speed, const char *plugin_name)
{
enumerator_t *enumerator;
rng_test_vector_t *vector;
@@ -883,8 +909,8 @@ METHOD(crypto_tester_t, test_rng, bool,
if (!this->rng_true && quality == RNG_TRUE)
{
- DBG1(DBG_LIB, "enabled %N: skipping test (disabled by config)",
- rng_quality_names, quality);
+ DBG1(DBG_LIB, "enabled %N[%s]: skipping test (disabled by config)",
+ rng_quality_names, quality, plugin_name);
return TRUE;
}
@@ -903,8 +929,8 @@ METHOD(crypto_tester_t, test_rng, bool,
rng = create(quality);
if (!rng)
{
- DBG1(DBG_LIB, "disabled %N: creating instance failed",
- rng_quality_names, quality);
+ DBG1(DBG_LIB, "disabled %N[%s]: creating instance failed",
+ rng_quality_names, quality, plugin_name);
failed = TRUE;
break;
}
@@ -933,17 +959,17 @@ METHOD(crypto_tester_t, test_rng, bool,
rng->destroy(rng);
if (failed)
{
- DBG1(DBG_LIB, "disabled %N: %s test vector failed",
- rng_quality_names, quality, get_name(vector));
+ DBG1(DBG_LIB, "disabled %N[%s]: %s test vector failed",
+ rng_quality_names, quality, plugin_name, get_name(vector));
break;
}
}
enumerator->destroy(enumerator);
if (!tested)
{
- DBG1(DBG_LIB, "%s %N: no test vectors found",
+ DBG1(DBG_LIB, "%s %N[%s]: no test vectors found",
this->required ? ", disabled" : "enabled ",
- rng_quality_names, quality);
+ rng_quality_names, quality, plugin_name);
return !this->required;
}
if (!failed)
@@ -951,13 +977,13 @@ METHOD(crypto_tester_t, test_rng, bool,
if (speed)
{
*speed = bench_rng(this, quality, create);
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors, %d points",
- rng_quality_names, quality, tested, *speed);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors, %d points",
+ rng_quality_names, quality, plugin_name, tested, *speed);
}
else
{
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors",
- rng_quality_names, quality, tested);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors",
+ rng_quality_names, quality, plugin_name, tested);
}
}
return !failed;
diff --git a/src/libstrongswan/crypto/crypto_tester.h b/src/libstrongswan/crypto/crypto_tester.h
index cef0b3c18..019c87c39 100644
--- a/src/libstrongswan/crypto/crypto_tester.h
+++ b/src/libstrongswan/crypto/crypto_tester.h
@@ -143,7 +143,7 @@ struct crypto_tester_t {
*/
bool (*test_crypter)(crypto_tester_t *this, encryption_algorithm_t alg,
size_t key_size, crypter_constructor_t create,
- u_int *speed);
+ u_int *speed, const char *plugin_name);
/**
* Test an aead algorithm, optionally using a specified key size.
@@ -156,7 +156,7 @@ struct crypto_tester_t {
*/
bool (*test_aead)(crypto_tester_t *this, encryption_algorithm_t alg,
size_t key_size, aead_constructor_t create,
- u_int *speed);
+ u_int *speed, const char *plugin_name);
/**
* Test a signer algorithm.
*
@@ -166,7 +166,8 @@ struct crypto_tester_t {
* @return TRUE if test passed
*/
bool (*test_signer)(crypto_tester_t *this, integrity_algorithm_t alg,
- signer_constructor_t create, u_int *speed);
+ signer_constructor_t create,
+ u_int *speed, const char *plugin_name);
/**
* Test a hasher algorithm.
*
@@ -176,7 +177,8 @@ struct crypto_tester_t {
* @return TRUE if test passed
*/
bool (*test_hasher)(crypto_tester_t *this, hash_algorithm_t alg,
- hasher_constructor_t create, u_int *speed);
+ hasher_constructor_t create,
+ u_int *speed, const char *plugin_name);
/**
* Test a PRF algorithm.
*
@@ -186,7 +188,8 @@ struct crypto_tester_t {
* @return TRUE if test passed
*/
bool (*test_prf)(crypto_tester_t *this, pseudo_random_function_t alg,
- prf_constructor_t create, u_int *speed);
+ prf_constructor_t create,
+ u_int *speed, const char *plugin_name);
/**
* Test a RNG implementation.
*
@@ -196,7 +199,8 @@ struct crypto_tester_t {
* @return TRUE if test passed
*/
bool (*test_rng)(crypto_tester_t *this, rng_quality_t quality,
- rng_constructor_t create, u_int *speed);
+ rng_constructor_t create,
+ u_int *speed, const char *plugin_name);
/**
* Add a test vector to test a crypter.
*
diff --git a/src/libstrongswan/eap/eap.h b/src/libstrongswan/eap/eap.h
index 1d55747a4..e98a3a211 100644
--- a/src/libstrongswan/eap/eap.h
+++ b/src/libstrongswan/eap/eap.h
@@ -82,7 +82,7 @@ extern enum_name_t *eap_type_short_names;
* Lookup the EAP method type from a string.
*
* @param name EAP method name (such as "md5", "aka")
- * @return method type, 0 if unkown
+ * @return method type, 0 if unknown
*/
eap_type_t eap_type_from_string(char *name);
diff --git a/src/libstrongswan/enum.c b/src/libstrongswan/enum.c
index 258a5b410..5c811bd17 100644
--- a/src/libstrongswan/enum.c
+++ b/src/libstrongswan/enum.c
@@ -43,7 +43,7 @@ int enum_from_name(enum_name_t *e, char *name)
{
do
{
- int i, count = e->last - e->first;
+ int i, count = e->last - e->first + 1;
for (i = 0; i < count; i++)
{
diff --git a/src/libstrongswan/fetcher/fetcher_manager.c b/src/libstrongswan/fetcher/fetcher_manager.c
index c81de032c..b007c8b08 100644
--- a/src/libstrongswan/fetcher/fetcher_manager.c
+++ b/src/libstrongswan/fetcher/fetcher_manager.c
@@ -92,7 +92,7 @@ static status_t fetch(private_fetcher_manager_t *this,
va_start(args, response);
while (good)
{
- opt = va_arg(args, fetcher_option_t);
+ opt = va_arg(args, int);
switch (opt)
{
case FETCH_REQUEST_DATA:
@@ -109,7 +109,7 @@ static status_t fetch(private_fetcher_manager_t *this,
good = fetcher->set_option(fetcher, opt, va_arg(args, u_int));
continue;
case FETCH_END:
- break;;
+ break;
}
break;
}
diff --git a/src/libstrongswan/integrity_checker.c b/src/libstrongswan/integrity_checker.c
index c9cad44ae..e962aba70 100644
--- a/src/libstrongswan/integrity_checker.c
+++ b/src/libstrongswan/integrity_checker.c
@@ -57,11 +57,8 @@ struct private_integrity_checker_t {
int checksum_count;
};
-/**
- * Implementation of integrity_checker_t.build_file
- */
-static u_int32_t build_file(private_integrity_checker_t *this, char *file,
- size_t *len)
+METHOD(integrity_checker_t, build_file, u_int32_t,
+ private_integrity_checker_t *this, char *file, size_t *len)
{
u_int32_t checksum;
chunk_t contents;
@@ -136,11 +133,8 @@ static int callback(struct dl_phdr_info *dlpi, size_t size, Dl_info *dli)
return 0;
}
-/**
- * Implementation of integrity_checker_t.build_segment
- */
-static u_int32_t build_segment(private_integrity_checker_t *this, void *sym,
- size_t *len)
+METHOD(integrity_checker_t, build_segment, u_int32_t,
+ private_integrity_checker_t *this, void *sym, size_t *len)
{
chunk_t segment;
Dl_info dli;
@@ -180,11 +174,8 @@ static integrity_checksum_t *find_checksum(private_integrity_checker_t *this,
return NULL;
}
-/**
- * Implementation of integrity_checker_t.check_file
- */
-static bool check_file(private_integrity_checker_t *this,
- char *name, char *file)
+METHOD(integrity_checker_t, check_file, bool,
+ private_integrity_checker_t *this, char *name, char *file)
{
integrity_checksum_t *cs;
u_int32_t sum;
@@ -217,11 +208,8 @@ static bool check_file(private_integrity_checker_t *this,
return TRUE;
}
-/**
- * Implementation of integrity_checker_t.check_segment
- */
-static bool check_segment(private_integrity_checker_t *this,
- char *name, void *sym)
+METHOD(integrity_checker_t, check_segment, bool,
+ private_integrity_checker_t *this, char *name, void *sym)
{
integrity_checksum_t *cs;
u_int32_t sum;
@@ -254,10 +242,8 @@ static bool check_segment(private_integrity_checker_t *this,
return TRUE;
}
-/**
- * Implementation of integrity_checker_t.check
- */
-static bool check(private_integrity_checker_t *this, char *name, void *sym)
+METHOD(integrity_checker_t, check, bool,
+ private_integrity_checker_t *this, char *name, void *sym)
{
Dl_info dli;
@@ -277,10 +263,8 @@ static bool check(private_integrity_checker_t *this, char *name, void *sym)
return TRUE;
}
-/**
- * Implementation of integrity_checker_t.destroy.
- */
-static void destroy(private_integrity_checker_t *this)
+METHOD(integrity_checker_t, destroy, void,
+ private_integrity_checker_t *this)
{
if (this->handle)
{
@@ -294,17 +278,19 @@ static void destroy(private_integrity_checker_t *this)
*/
integrity_checker_t *integrity_checker_create(char *checksum_library)
{
- private_integrity_checker_t *this = malloc_thing(private_integrity_checker_t);
-
- this->public.check_file = (bool(*)(integrity_checker_t*, char *name, char *file))check_file;
- this->public.build_file = (u_int32_t(*)(integrity_checker_t*, char *file, size_t *len))build_file;
- this->public.check_segment = (bool(*)(integrity_checker_t*, char *name, void *sym))check_segment;
- this->public.build_segment = (u_int32_t(*)(integrity_checker_t*, void *sym, size_t *len))build_segment;
- this->public.check = (bool(*)(integrity_checker_t*, char *name, void *sym))check;
- this->public.destroy = (void(*)(integrity_checker_t*))destroy;
+ private_integrity_checker_t *this;
+
+ INIT(this,
+ .public = {
+ .check_file = _check_file,
+ .build_file = _build_file,
+ .check_segment = _check_segment,
+ .build_segment = _build_segment,
+ .check = _check,
+ .destroy = _destroy,
+ },
+ );
- this->checksum_count = 0;
- this->handle = NULL;
if (checksum_library)
{
this->handle = dlopen(checksum_library, RTLD_LAZY);
diff --git a/src/libstrongswan/plugins/aes/Makefile.in b/src/libstrongswan/plugins/aes/Makefile.in
index 99a520852..9835cd5b9 100644
--- a/src/libstrongswan/plugins/aes/Makefile.in
+++ b/src/libstrongswan/plugins/aes/Makefile.in
@@ -219,9 +219,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -260,6 +258,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/aes/aes_plugin.c b/src/libstrongswan/plugins/aes/aes_plugin.c
index 22b47e334..1c060b6c8 100644
--- a/src/libstrongswan/plugins/aes/aes_plugin.c
+++ b/src/libstrongswan/plugins/aes/aes_plugin.c
@@ -18,6 +18,8 @@
#include <library.h>
#include "aes_crypter.h"
+static const char *plugin_name = "aes";
+
typedef struct private_aes_plugin_t private_aes_plugin_t;
/**
@@ -54,7 +56,7 @@ plugin_t *aes_plugin_create()
},
);
- lib->crypto->add_crypter(lib->crypto, ENCR_AES_CBC,
+ lib->crypto->add_crypter(lib->crypto, ENCR_AES_CBC, plugin_name,
(crypter_constructor_t)aes_crypter_create);
return &this->public.plugin;
diff --git a/src/libstrongswan/plugins/af_alg/Makefile.am b/src/libstrongswan/plugins/af_alg/Makefile.am
new file mode 100644
index 000000000..a33fd30b6
--- /dev/null
+++ b/src/libstrongswan/plugins/af_alg/Makefile.am
@@ -0,0 +1,20 @@
+
+INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan
+
+AM_CFLAGS = -rdynamic
+
+if MONOLITHIC
+noinst_LTLIBRARIES = libstrongswan-af-alg.la
+else
+plugin_LTLIBRARIES = libstrongswan-af-alg.la
+endif
+
+libstrongswan_af_alg_la_SOURCES = \
+ af_alg_plugin.h af_alg_plugin.c \
+ af_alg_ops.h af_alg_ops.c \
+ af_alg_hasher.h af_alg_hasher.c \
+ af_alg_signer.h af_alg_signer.c \
+ af_alg_prf.h af_alg_prf.c \
+ af_alg_crypter.h af_alg_crypter.c
+
+libstrongswan_af_alg_la_LDFLAGS = -module -avoid-version
diff --git a/src/libstrongswan/plugins/af_alg/Makefile.in b/src/libstrongswan/plugins/af_alg/Makefile.in
new file mode 100644
index 000000000..aa8df979e
--- /dev/null
+++ b/src/libstrongswan/plugins/af_alg/Makefile.in
@@ -0,0 +1,612 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/libstrongswan/plugins/af_alg
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/config/libtool.m4 \
+ $(top_srcdir)/m4/config/ltoptions.m4 \
+ $(top_srcdir)/m4/config/ltsugar.m4 \
+ $(top_srcdir)/m4/config/ltversion.m4 \
+ $(top_srcdir)/m4/config/lt~obsolete.m4 \
+ $(top_srcdir)/m4/macros/with.m4 \
+ $(top_srcdir)/m4/macros/enable-disable.m4 \
+ $(top_srcdir)/m4/macros/add-plugin.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(plugindir)"
+LTLIBRARIES = $(noinst_LTLIBRARIES) $(plugin_LTLIBRARIES)
+libstrongswan_af_alg_la_LIBADD =
+am_libstrongswan_af_alg_la_OBJECTS = af_alg_plugin.lo af_alg_ops.lo \
+ af_alg_hasher.lo af_alg_signer.lo af_alg_prf.lo \
+ af_alg_crypter.lo
+libstrongswan_af_alg_la_OBJECTS = \
+ $(am_libstrongswan_af_alg_la_OBJECTS)
+libstrongswan_af_alg_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(libstrongswan_af_alg_la_LDFLAGS) $(LDFLAGS) -o $@
+@MONOLITHIC_FALSE@am_libstrongswan_af_alg_la_rpath = -rpath \
+@MONOLITHIC_FALSE@ $(plugindir)
+@MONOLITHIC_TRUE@am_libstrongswan_af_alg_la_rpath =
+DEFAULT_INCLUDES = -I.@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libstrongswan_af_alg_la_SOURCES)
+DIST_SOURCES = $(libstrongswan_af_alg_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BTLIB = @BTLIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLIB = @DLLIB@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GPERF = @GPERF@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MYSQLCFLAG = @MYSQLCFLAG@
+MYSQLCONFIG = @MYSQLCONFIG@
+MYSQLLIB = @MYSQLLIB@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PTHREADLIB = @PTHREADLIB@
+RANLIB = @RANLIB@
+RTLIB = @RTLIB@
+RUBY = @RUBY@
+RUBYINCLUDE = @RUBYINCLUDE@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOCKLIB = @SOCKLIB@
+STRIP = @STRIP@
+VERSION = @VERSION@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+c_plugins = @c_plugins@
+datadir = @datadir@
+datarootdir = @datarootdir@
+dbusservicedir = @dbusservicedir@
+default_pkcs11 = @default_pkcs11@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+gtk_CFLAGS = @gtk_CFLAGS@
+gtk_LIBS = @gtk_LIBS@
+h_plugins = @h_plugins@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+ipsecdir = @ipsecdir@
+ipsecgroup = @ipsecgroup@
+ipsecuser = @ipsecuser@
+libcharon_plugins = @libcharon_plugins@
+libdir = @libdir@
+libexecdir = @libexecdir@
+linux_headers = @linux_headers@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+maemo_CFLAGS = @maemo_CFLAGS@
+maemo_LIBS = @maemo_LIBS@
+manager_plugins = @manager_plugins@
+mandir = @mandir@
+medsrv_plugins = @medsrv_plugins@
+mkdir_p = @mkdir_p@
+nm_CFLAGS = @nm_CFLAGS@
+nm_LIBS = @nm_LIBS@
+nm_ca_dir = @nm_ca_dir@
+oldincludedir = @oldincludedir@
+openac_plugins = @openac_plugins@
+p_plugins = @p_plugins@
+pdfdir = @pdfdir@
+piddir = @piddir@
+pki_plugins = @pki_plugins@
+plugindir = @plugindir@
+pluto_plugins = @pluto_plugins@
+pool_plugins = @pool_plugins@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+random_device = @random_device@
+resolv_conf = @resolv_conf@
+routing_table = @routing_table@
+routing_table_prio = @routing_table_prio@
+s_plugins = @s_plugins@
+sbindir = @sbindir@
+scepclient_plugins = @scepclient_plugins@
+scripts_plugins = @scripts_plugins@
+sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
+srcdir = @srcdir@
+strongswan_conf = @strongswan_conf@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+urandom_device = @urandom_device@
+xml_CFLAGS = @xml_CFLAGS@
+xml_LIBS = @xml_LIBS@
+INCLUDES = -I${linux_headers} -I$(top_srcdir)/src/libstrongswan
+AM_CFLAGS = -rdynamic
+@MONOLITHIC_TRUE@noinst_LTLIBRARIES = libstrongswan-af-alg.la
+@MONOLITHIC_FALSE@plugin_LTLIBRARIES = libstrongswan-af-alg.la
+libstrongswan_af_alg_la_SOURCES = \
+ af_alg_plugin.h af_alg_plugin.c \
+ af_alg_ops.h af_alg_ops.c \
+ af_alg_hasher.h af_alg_hasher.c \
+ af_alg_signer.h af_alg_signer.c \
+ af_alg_prf.h af_alg_prf.c \
+ af_alg_crypter.h af_alg_crypter.c
+
+libstrongswan_af_alg_la_LDFLAGS = -module -avoid-version
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/libstrongswan/plugins/af_alg/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/libstrongswan/plugins/af_alg/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(plugindir)" || $(MKDIR_P) "$(DESTDIR)$(plugindir)"
+ @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \
+ }
+
+uninstall-pluginLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \
+ done
+
+clean-pluginLTLIBRARIES:
+ -test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES)
+ @list='$(plugin_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libstrongswan-af-alg.la: $(libstrongswan_af_alg_la_OBJECTS) $(libstrongswan_af_alg_la_DEPENDENCIES)
+ $(libstrongswan_af_alg_la_LINK) $(am_libstrongswan_af_alg_la_rpath) $(libstrongswan_af_alg_la_OBJECTS) $(libstrongswan_af_alg_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/af_alg_crypter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/af_alg_hasher.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/af_alg_ops.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/af_alg_plugin.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/af_alg_prf.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/af_alg_signer.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(plugindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ clean-pluginLTLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pluginLTLIBRARIES
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pluginLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLTLIBRARIES clean-pluginLTLIBRARIES \
+ ctags distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-pluginLTLIBRARIES install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am \
+ uninstall-pluginLTLIBRARIES
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_crypter.c b/src/libstrongswan/plugins/af_alg/af_alg_crypter.c
new file mode 100644
index 000000000..3416ad8d2
--- /dev/null
+++ b/src/libstrongswan/plugins/af_alg/af_alg_crypter.c
@@ -0,0 +1,237 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include "af_alg_crypter.h"
+#include "af_alg_ops.h"
+
+typedef struct private_af_alg_crypter_t private_af_alg_crypter_t;
+
+/**
+ * Private data of af_alg_crypter_t
+ */
+struct private_af_alg_crypter_t {
+
+ /**
+ * Public part of this class.
+ */
+ af_alg_crypter_t public;
+
+ /**
+ * AF_ALG operations
+ */
+ af_alg_ops_t *ops;
+
+ /**
+ * Size of the truncated signature
+ */
+ size_t block_size;
+
+ /**
+ * Size of the keymat
+ */
+ size_t keymat_size;
+
+ /**
+ * Size of initialization vector
+ */
+ size_t iv_size;
+};
+
+/**
+ * Algorithm database
+ */
+static struct {
+ encryption_algorithm_t id;
+ char *name;
+ size_t block_size;
+ /* key size of the algorithm */
+ size_t key_size;
+ /* size of the keying material (key + nonce for ctr mode) */
+ size_t keymat_size;
+ size_t iv_size;
+} algs[] = {
+ {ENCR_DES, "cbc(des)", 8, 8, 8, 8, },
+ {ENCR_3DES, "cbc(des3_ede)", 8, 24, 24, 8, },
+ {ENCR_AES_CBC, "cbc(aes)", 16, 16, 16, 16, },
+ {ENCR_AES_CBC, "cbc(aes)", 16, 24, 24, 16, },
+ {ENCR_AES_CBC, "cbc(aes)", 16, 32, 32, 16, },
+ {ENCR_AES_CTR, "rfc3686(ctr(aes))", 1, 16, 20, 8, },
+ {ENCR_AES_CTR, "rfc3686(ctr(aes))", 1, 24, 28, 8, },
+ {ENCR_AES_CTR, "rfc3686(ctr(aes))", 1, 32, 36, 8, },
+ {ENCR_CAMELLIA_CBC, "cbc(camellia)", 16, 16, 16, 16, },
+ {ENCR_CAMELLIA_CBC, "cbc(camellia)", 16, 24, 24, 16, },
+ {ENCR_CAMELLIA_CBC, "cbc(camellia)", 16, 32, 32, 16, },
+ {ENCR_CAMELLIA_CTR, "rfc3686(ctr(camellia))", 1, 16, 20, 8, },
+ {ENCR_CAMELLIA_CTR, "rfc3686(ctr(camellia))", 1, 24, 28, 8, },
+ {ENCR_CAMELLIA_CTR, "rfc3686(ctr(camellia))", 1, 32, 36, 8, },
+ {ENCR_CAST, "cbc(cast5)", 8, 16, 16, 8, },
+ {ENCR_BLOWFISH, "cbc(blowfish)", 8, 16, 16, 8, },
+ {ENCR_BLOWFISH, "cbc(blowfish)", 8, 24, 24, 8, },
+ {ENCR_BLOWFISH, "cbc(blowfish)", 8, 32, 32, 8, },
+ {ENCR_SERPENT_CBC, "cbc(serpent)", 16, 16, 16, 16, },
+ {ENCR_SERPENT_CBC, "cbc(serpent)", 16, 24, 24, 16, },
+ {ENCR_SERPENT_CBC, "cbc(serpent)", 16, 32, 32, 16, },
+ {ENCR_TWOFISH_CBC, "cbc(twofish)", 16, 16, 16, 16, },
+ {ENCR_TWOFISH_CBC, "cbc(twofish)", 16, 24, 24, 16, },
+ {ENCR_TWOFISH_CBC, "cbc(twofish)", 16, 32, 32, 16, },
+};
+
+/**
+ * See header.
+ */
+void af_alg_crypter_probe()
+{
+ encryption_algorithm_t prev = -1;
+ af_alg_ops_t *ops;
+ int i;
+
+ for (i = 0; i < countof(algs); i++)
+ {
+ if (prev != algs[i].id)
+ {
+ ops = af_alg_ops_create("skcipher", algs[i].name);
+ if (ops)
+ {
+ ops->destroy(ops);
+ lib->crypto->add_crypter(lib->crypto, algs[i].id, af_alg_plugin_name,
+ (crypter_constructor_t)af_alg_crypter_create);
+ }
+ }
+ prev = algs[i].id;
+ }
+}
+
+/**
+ * Get the kernel algorithm string and block/key size for our identifier
+ */
+static size_t lookup_alg(encryption_algorithm_t algo, char **name,
+ size_t key_size, size_t *keymat_size, size_t *iv_size)
+{
+ int i;
+
+ for (i = 0; i < countof(algs); i++)
+ {
+ if (algs[i].id == algo &&
+ (key_size == 0 || algs[i].key_size == key_size))
+ {
+ *name = algs[i].name;
+ *keymat_size = algs[i].keymat_size;
+ *iv_size = algs[i].iv_size;
+ return algs[i].block_size;
+ }
+ }
+ return 0;
+}
+
+METHOD(crypter_t, decrypt, void,
+ private_af_alg_crypter_t *this, chunk_t data, chunk_t iv, chunk_t *dst)
+{
+ if (dst)
+ {
+ *dst = chunk_alloc(data.len);
+ this->ops->crypt(this->ops, ALG_OP_DECRYPT, iv, data, dst->ptr);
+ }
+ else
+ {
+ this->ops->crypt(this->ops, ALG_OP_DECRYPT, iv, data, data.ptr);
+ }
+}
+
+METHOD(crypter_t, encrypt, void,
+ private_af_alg_crypter_t *this, chunk_t data, chunk_t iv, chunk_t *dst)
+{
+ if (dst)
+ {
+ *dst = chunk_alloc(data.len);
+ this->ops->crypt(this->ops, ALG_OP_ENCRYPT, iv, data, dst->ptr);
+ }
+ else
+ {
+ this->ops->crypt(this->ops, ALG_OP_ENCRYPT, iv, data, data.ptr);
+ }
+}
+
+METHOD(crypter_t, get_block_size, size_t,
+ private_af_alg_crypter_t *this)
+{
+ return this->block_size;
+}
+
+METHOD(crypter_t, get_iv_size, size_t,
+ private_af_alg_crypter_t *this)
+{
+ return this->iv_size;
+}
+
+METHOD(crypter_t, get_key_size, size_t,
+ private_af_alg_crypter_t *this)
+{
+ return this->keymat_size;
+}
+
+METHOD(crypter_t, set_key, void,
+ private_af_alg_crypter_t *this, chunk_t key)
+{
+ this->ops->set_key(this->ops, key);
+}
+
+METHOD(crypter_t, destroy, void,
+ private_af_alg_crypter_t *this)
+{
+ this->ops->destroy(this->ops);
+ free(this);
+}
+
+/*
+ * Described in header
+ */
+af_alg_crypter_t *af_alg_crypter_create(encryption_algorithm_t algo,
+ size_t key_size)
+{
+ private_af_alg_crypter_t *this;
+ size_t block_size, keymat_size, iv_size;
+ char *name;
+
+ block_size = lookup_alg(algo, &name, key_size, &keymat_size, &iv_size);
+ if (!block_size)
+ { /* not supported by kernel */
+ return NULL;
+ }
+
+ INIT(this,
+ .public = {
+ .crypter = {
+ .encrypt = _encrypt,
+ .decrypt = _decrypt,
+ .get_block_size = _get_block_size,
+ .get_iv_size = _get_iv_size,
+ .get_key_size = _get_key_size,
+ .set_key = _set_key,
+ .destroy = _destroy,
+ },
+ },
+ .block_size = block_size,
+ .keymat_size = keymat_size,
+ .iv_size = iv_size,
+ .ops = af_alg_ops_create("skcipher", name),
+ );
+
+ if (!this->ops)
+ {
+ free(this);
+ return NULL;
+ }
+ return &this->public;
+}
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_crypter.h b/src/libstrongswan/plugins/af_alg/af_alg_crypter.h
new file mode 100644
index 000000000..711d2fc35
--- /dev/null
+++ b/src/libstrongswan/plugins/af_alg/af_alg_crypter.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup af_alg_crypter af_alg_crypter
+ * @{ @ingroup af_alg
+ */
+
+#ifndef AF_ALG_CRYPTER_H_
+#define AF_ALG_CRYPTER_H_
+
+typedef struct af_alg_crypter_t af_alg_crypter_t;
+
+#include <crypto/crypters/crypter.h>
+
+/**
+ * Implementation of signers using AF_ALG.
+ */
+struct af_alg_crypter_t {
+
+ /**
+ * The crypter_t interface.
+ */
+ crypter_t crypter;
+};
+
+/**
+ * Constructor to create af_alg_crypter_t.
+ *
+ * @param algo algorithm to implement
+ * @param key_size key size in bytes
+ * @return af_alg_crypter_t, NULL if not supported
+ */
+af_alg_crypter_t *af_alg_crypter_create(encryption_algorithm_t algo,
+ size_t key_size);
+
+/**
+ * Probe algorithms and register af_alg_crypter_create().
+ */
+void af_alg_crypter_probe();
+
+#endif /** AF_ALG_CRYPTER_H_ @}*/
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_hasher.c b/src/libstrongswan/plugins/af_alg/af_alg_hasher.c
new file mode 100644
index 000000000..7c6297d44
--- /dev/null
+++ b/src/libstrongswan/plugins/af_alg/af_alg_hasher.c
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include "af_alg_hasher.h"
+#include "af_alg_ops.h"
+
+typedef struct private_af_alg_hasher_t private_af_alg_hasher_t;
+
+/**
+ * Private data of af_alg_hasher_t
+ */
+struct private_af_alg_hasher_t {
+
+ /**
+ * Public part of this class.
+ */
+ af_alg_hasher_t public;
+
+ /**
+ * AF_ALG operations
+ */
+ af_alg_ops_t *ops;
+
+ /**
+ * Size of the hash
+ */
+ size_t size;
+};
+
+/**
+ * Algorithm database
+ */
+static struct {
+ hash_algorithm_t id;
+ char *name;
+ size_t size;
+} algs[] = {
+ {HASH_SHA1, "sha1", HASH_SIZE_SHA1 },
+ {HASH_MD5, "md5", HASH_SIZE_MD5 },
+ {HASH_SHA224, "sha224", HASH_SIZE_SHA224 },
+ {HASH_SHA256, "sha256", HASH_SIZE_SHA256 },
+ {HASH_SHA384, "sha384", HASH_SIZE_SHA384 },
+ {HASH_SHA512, "sha512", HASH_SIZE_SHA512 },
+ {HASH_MD4, "md4", HASH_SIZE_MD4 },
+};
+
+/**
+ * See header.
+ */
+void af_alg_hasher_probe()
+{
+ af_alg_ops_t *ops;
+ int i;
+
+ for (i = 0; i < countof(algs); i++)
+ {
+ ops = af_alg_ops_create("hash", algs[i].name);
+ if (ops)
+ {
+ ops->destroy(ops);
+ lib->crypto->add_hasher(lib->crypto, algs[i].id, af_alg_plugin_name,
+ (hasher_constructor_t)af_alg_hasher_create);
+ }
+ }
+}
+
+/**
+ * Get the kernel algorithm string and hash size for our identifier
+ */
+static size_t lookup_alg(hash_algorithm_t algo, char **name)
+{
+ int i;
+
+ for (i = 0; i < countof(algs); i++)
+ {
+ if (algs[i].id == algo)
+ {
+ *name = algs[i].name;
+ return algs[i].size;
+ }
+ }
+ return 0;
+}
+
+METHOD(hasher_t, get_hash_size, size_t,
+ private_af_alg_hasher_t *this)
+{
+ return this->size;
+}
+
+METHOD(hasher_t, reset, void,
+ private_af_alg_hasher_t *this)
+{
+ this->ops->reset(this->ops);
+}
+
+METHOD(hasher_t, get_hash, void,
+ private_af_alg_hasher_t *this, chunk_t chunk, u_int8_t *hash)
+{
+ this->ops->hash(this->ops, chunk, hash, this->size);
+}
+
+METHOD(hasher_t, allocate_hash, void,
+ private_af_alg_hasher_t *this, chunk_t chunk, chunk_t *hash)
+{
+ if (hash)
+ {
+ *hash = chunk_alloc(get_hash_size(this));
+ get_hash(this, chunk, hash->ptr);
+ }
+ else
+ {
+ get_hash(this, chunk, NULL);
+ }
+}
+
+METHOD(hasher_t, destroy, void,
+ private_af_alg_hasher_t *this)
+{
+ this->ops->destroy(this->ops);
+ free(this);
+}
+
+/*
+ * Described in header
+ */
+af_alg_hasher_t *af_alg_hasher_create(hash_algorithm_t algo)
+{
+ private_af_alg_hasher_t *this;
+ char *name;
+ size_t size;
+
+ size = lookup_alg(algo, &name);
+ if (!size)
+ { /* not supported by kernel */
+ return NULL;
+ }
+
+ INIT(this,
+ .public = {
+ .hasher = {
+ .get_hash = _get_hash,
+ .allocate_hash = _allocate_hash,
+ .get_hash_size = _get_hash_size,
+ .reset = _reset,
+ .destroy = _destroy,
+ },
+ },
+ .ops = af_alg_ops_create("hash", name),
+ .size = size,
+ );
+ if (!this->ops)
+ {
+ free(this);
+ return NULL;
+ }
+ return &this->public;
+}
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_hasher.h b/src/libstrongswan/plugins/af_alg/af_alg_hasher.h
new file mode 100644
index 000000000..e0833e23a
--- /dev/null
+++ b/src/libstrongswan/plugins/af_alg/af_alg_hasher.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup af_alg_hasher af_alg_hasher
+ * @{ @ingroup af_alg
+ */
+
+#ifndef af_alg_HASHER_H_
+#define af_alg_HASHER_H_
+
+typedef struct af_alg_hasher_t af_alg_hasher_t;
+
+#include <crypto/hashers/hasher.h>
+
+/**
+ * Implementation of hashers using AF_ALG.
+ */
+struct af_alg_hasher_t {
+
+ /**
+ * Implements hasher_t interface.
+ */
+ hasher_t hasher;
+};
+
+/**
+ * Constructor to create af_alg_hasher_t.
+ *
+ * @param algo algorithm
+ * @return af_alg_hasher_t, NULL if not supported
+ */
+af_alg_hasher_t *af_alg_hasher_create(hash_algorithm_t algo);
+
+/**
+ * Probe algorithms and register af_alg_hasher_create().
+ */
+void af_alg_hasher_probe();
+
+#endif /** af_alg_HASHER_H_ @}*/
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_ops.c b/src/libstrongswan/plugins/af_alg/af_alg_ops.c
new file mode 100644
index 000000000..7bf1d90db
--- /dev/null
+++ b/src/libstrongswan/plugins/af_alg/af_alg_ops.c
@@ -0,0 +1,226 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include "af_alg_ops.h"
+
+#include <unistd.h>
+#include <errno.h>
+#include <linux/socket.h>
+
+#include <debug.h>
+
+const char *af_alg_plugin_name = "af-alg";
+
+typedef struct private_af_alg_ops_t private_af_alg_ops_t;
+
+/**
+ * Private data of an af_alg_ops_t object.
+ */
+struct private_af_alg_ops_t {
+
+ /**
+ * Public af_alg_ops_t interface.
+ */
+ af_alg_ops_t public;
+
+ /**
+ * Transform FD
+ */
+ int tfm;
+
+ /**
+ * Operation FD
+ */
+ int op;
+};
+
+METHOD(af_alg_ops_t, reset, void,
+ private_af_alg_ops_t *this)
+{
+ if (this->op != -1)
+ {
+ close(this->op);
+ this->op = -1;
+ }
+}
+
+METHOD(af_alg_ops_t, hash, void,
+ private_af_alg_ops_t *this, chunk_t data, char *out, size_t outlen)
+{
+ ssize_t len;
+
+ while (this->op == -1)
+ {
+ this->op = accept(this->tfm, NULL, 0);
+ if (this->op == -1)
+ {
+ DBG1(DBG_LIB, "opening AF_ALG hasher failed: %s", strerror(errno));
+ sleep(1);
+ }
+ }
+ do
+ {
+ len = send(this->op, data.ptr, data.len, out ? 0 : MSG_MORE);
+ if (len == -1)
+ {
+ DBG1(DBG_LIB, "writing to AF_ALG hasher failed: %s", strerror(errno));
+ sleep(1);
+ }
+ else
+ {
+ data = chunk_skip(data, len);
+ }
+ }
+ while (data.len);
+
+ if (out)
+ {
+ while (read(this->op, out, outlen) != outlen)
+ {
+ DBG1(DBG_LIB, "reading AF_ALG hasher failed: %s", strerror(errno));
+ sleep(1);
+ }
+ reset(this);
+ }
+}
+
+METHOD(af_alg_ops_t, crypt, void,
+ private_af_alg_ops_t *this, u_int32_t type, chunk_t iv, chunk_t data,
+ char *out)
+{
+ struct msghdr msg = {};
+ struct cmsghdr *cmsg;
+ struct af_alg_iv *ivm;
+ struct iovec iov;
+ char buf[CMSG_SPACE(sizeof(type)) +
+ CMSG_SPACE(offsetof(struct af_alg_iv, iv) + iv.len)];
+ ssize_t len;
+ int op;
+
+ while ((op = accept(this->tfm, NULL, 0)) == -1)
+ {
+ DBG1(DBG_LIB, "accepting AF_ALG crypter failed: %s", strerror(errno));
+ sleep(1);
+ }
+
+ memset(buf, 0, sizeof(buf));
+
+ msg.msg_control = buf;
+ msg.msg_controllen = sizeof(buf);
+
+ cmsg = CMSG_FIRSTHDR(&msg);
+ cmsg->cmsg_level = SOL_ALG;
+ cmsg->cmsg_type = ALG_SET_OP;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(type));
+ *(u_int32_t*)CMSG_DATA(cmsg) = type;
+
+ cmsg = CMSG_NXTHDR(&msg, cmsg);
+ cmsg->cmsg_level = SOL_ALG;
+ cmsg->cmsg_type = ALG_SET_IV;
+ cmsg->cmsg_len = CMSG_LEN(offsetof(struct af_alg_iv, iv) + iv.len);
+ ivm = (void*)CMSG_DATA(cmsg);
+ ivm->ivlen = iv.len;
+ memcpy(ivm->iv, iv.ptr, iv.len);
+
+ msg.msg_iov = &iov;
+ msg.msg_iovlen = 1;
+
+ while (data.len)
+ {
+ iov.iov_base = data.ptr;
+ iov.iov_len = data.len;
+
+ len = sendmsg(op, &msg, 0);
+ if (len == -1)
+ {
+ DBG1(DBG_LIB, "writing to AF_ALG crypter failed: %s",
+ strerror(errno));
+ sleep(1);
+ continue;
+ }
+ if (read(op, out, len) != len)
+ {
+ DBG1(DBG_LIB, "reading from AF_ALG crypter failed: %s",
+ strerror(errno));
+ }
+ data = chunk_skip(data, len);
+ /* no IV for subsequent data chunks */
+ msg.msg_controllen = 0;
+ }
+ close(op);
+}
+
+METHOD(af_alg_ops_t, set_key, void,
+ private_af_alg_ops_t *this, chunk_t key)
+{
+ if (setsockopt(this->tfm, SOL_ALG, ALG_SET_KEY, key.ptr, key.len) == -1)
+ {
+ DBG1(DBG_LIB, "setting AF_ALG key failed: %s", strerror(errno));
+ }
+}
+
+METHOD(af_alg_ops_t, destroy, void,
+ private_af_alg_ops_t *this)
+{
+ close(this->tfm);
+ if (this->op != -1)
+ {
+ close(this->op);
+ }
+ free(this);
+}
+
+/**
+ * See header
+ */
+af_alg_ops_t *af_alg_ops_create(char *type, char *alg)
+{
+ private_af_alg_ops_t *this;
+ struct sockaddr_alg sa = {
+ .salg_family = AF_ALG,
+ };
+
+ strncpy(sa.salg_type, type, sizeof(sa.salg_type));
+ strncpy(sa.salg_name, alg, sizeof(sa.salg_name));
+
+ INIT(this,
+ .public = {
+ .hash = _hash,
+ .reset = _reset,
+ .crypt = _crypt,
+ .set_key = _set_key,
+ .destroy = _destroy,
+ },
+ .tfm = socket(AF_ALG, SOCK_SEQPACKET, 0),
+ .op = -1,
+ );
+ if (this->tfm == -1)
+ {
+ DBG1(DBG_LIB, "opening AF_ALG socket failed: %s", strerror(errno));
+ free(this);
+ return NULL;
+ }
+ if (bind(this->tfm, (struct sockaddr*)&sa, sizeof(sa)) == -1)
+ {
+ if (errno != ENOENT)
+ { /* fail silently if algorithm not supported */
+ DBG1(DBG_LIB, "binding AF_ALG socket for '%s' failed: %s",
+ sa.salg_name, strerror(errno));
+ }
+ destroy(this);
+ return NULL;
+ }
+ return &this->public;
+}
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_ops.h b/src/libstrongswan/plugins/af_alg/af_alg_ops.h
new file mode 100644
index 000000000..b7d642c00
--- /dev/null
+++ b/src/libstrongswan/plugins/af_alg/af_alg_ops.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+/**
+* @defgroup af_alg_ops af_alg_ops
+ * @{ @ingroup af_alg
+ */
+
+#ifndef AF_ALG_OPS_H_
+#define AF_ALG_OPS_H_
+
+#include <library.h>
+
+#include <linux/if_alg.h>
+
+#ifndef AF_ALG
+#define AF_ALG 38
+#endif /* AF_ALG */
+
+#ifndef SOL_ALG
+#define SOL_ALG 279
+#endif /* SOL_ALG */
+
+extern const char *af_alg_plugin_name;
+
+typedef struct af_alg_ops_t af_alg_ops_t;
+
+/**
+ * Helper to run AF_ALG operations.
+ */
+struct af_alg_ops_t {
+
+ /**
+ * Hash a chunk of data.
+ *
+ * @param data data to hash
+ * @param out buffer to write hash to, NULL for append mode
+ * @param outlen number of bytes to read into out
+ */
+ void (*hash)(af_alg_ops_t *this, chunk_t data, char *out, size_t outlen);
+
+ /**
+ * Reset hasher state.
+ */
+ void (*reset)(af_alg_ops_t *this);
+
+ /**
+ * En-/Decrypt a chunk of data.
+ *
+ * @param type crypto operation (ALG_OP_DECRYPT/ALG_OP_ENCRYPT)
+ * @param iv iv to use
+ * @param data data to encrypt/decrypt
+ * @param out buffer write processed data to
+ */
+ void (*crypt)(af_alg_ops_t *this, u_int32_t type, chunk_t iv, chunk_t data,
+ char *out);
+
+ /**
+ * Set the key for en-/decryption or HMAC/XCBC operations.
+ *
+ * @param key key to set for transform
+ */
+ void (*set_key)(af_alg_ops_t *this, chunk_t key);
+
+ /**
+ * Destroy a af_alg_ops_t.
+ */
+ void (*destroy)(af_alg_ops_t *this);
+};
+
+/**
+ * Create a af_alg_ops instance.
+ *
+ * @param type algorithm type (hash, skcipher)
+ * @param alg algorithm name
+ * @return TRUE if AF_ALG socket bound successfully
+ */
+af_alg_ops_t *af_alg_ops_create(char *type, char *alg);
+
+#endif /** AF_ALG_OPS_H_ @}*/
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_plugin.c b/src/libstrongswan/plugins/af_alg/af_alg_plugin.c
new file mode 100644
index 000000000..54e39f1a0
--- /dev/null
+++ b/src/libstrongswan/plugins/af_alg/af_alg_plugin.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include "af_alg_plugin.h"
+
+#include <library.h>
+
+#include "af_alg_hasher.h"
+#include "af_alg_signer.h"
+#include "af_alg_prf.h"
+#include "af_alg_crypter.h"
+
+typedef struct private_af_alg_plugin_t private_af_alg_plugin_t;
+
+/**
+ * private data of af_alg_plugin
+ */
+struct private_af_alg_plugin_t {
+
+ /**
+ * public functions
+ */
+ af_alg_plugin_t public;
+};
+
+METHOD(plugin_t, destroy, void,
+ private_af_alg_plugin_t *this)
+{
+ lib->crypto->remove_hasher(lib->crypto,
+ (hasher_constructor_t)af_alg_hasher_create);
+ lib->crypto->remove_signer(lib->crypto,
+ (signer_constructor_t)af_alg_signer_create);
+ lib->crypto->remove_prf(lib->crypto,
+ (prf_constructor_t)af_alg_prf_create);
+ lib->crypto->remove_crypter(lib->crypto,
+ (crypter_constructor_t)af_alg_crypter_create);
+
+ free(this);
+}
+
+/*
+ * see header file
+ */
+plugin_t *af_alg_plugin_create()
+{
+ private_af_alg_plugin_t *this;
+
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
+
+ af_alg_hasher_probe();
+ af_alg_signer_probe();
+ af_alg_prf_probe();
+ af_alg_crypter_probe();
+
+ return &this->public.plugin;
+}
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_plugin.h b/src/libstrongswan/plugins/af_alg/af_alg_plugin.h
new file mode 100644
index 000000000..18c069831
--- /dev/null
+++ b/src/libstrongswan/plugins/af_alg/af_alg_plugin.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup af_alg af_alg
+ * @ingroup plugins
+ *
+ * @defgroup af_alg_plugin af_alg_plugin
+ * @{ @ingroup af_alg
+ */
+
+#ifndef AF_ALG_PLUGIN_H_
+#define AF_ALG_PLUGIN_H_
+
+#include <plugins/plugin.h>
+
+typedef struct af_alg_plugin_t af_alg_plugin_t;
+
+/**
+ * Plugin providing the AF_ALG interface to the Linux Crypto API.
+ */
+struct af_alg_plugin_t {
+
+ /**
+ * Implements plugin interface.
+ */
+ plugin_t plugin;
+};
+
+#endif /** AF_ALG_PLUGIN_H_ @}*/
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_prf.c b/src/libstrongswan/plugins/af_alg/af_alg_prf.c
new file mode 100644
index 000000000..575906bae
--- /dev/null
+++ b/src/libstrongswan/plugins/af_alg/af_alg_prf.c
@@ -0,0 +1,211 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include "af_alg_prf.h"
+#include "af_alg_ops.h"
+
+typedef struct private_af_alg_prf_t private_af_alg_prf_t;
+
+/**
+ * Private data of a af_alg_prf_t object.
+ */
+struct private_af_alg_prf_t {
+
+ /**
+ * Public af_alg_prf_t interface.
+ */
+ af_alg_prf_t public;
+
+ /**
+ * AF_ALG operations
+ */
+ af_alg_ops_t *ops;
+
+ /**
+ * Size of the PRF output
+ */
+ size_t block_size;
+
+ /**
+ * Default key size
+ */
+ size_t key_size;
+
+ /**
+ * Using an XCBC algorithm?
+ */
+ bool xcbc;
+};
+
+/**
+ * Algorithm database
+ */
+static struct {
+ pseudo_random_function_t id;
+ char *name;
+ size_t block_size;
+ bool xcbc;
+} algs[] = {
+ {PRF_HMAC_SHA1, "hmac(sha1)", 20, FALSE, },
+ {PRF_HMAC_SHA2_256, "hmac(sha256)", 32, FALSE, },
+ {PRF_HMAC_MD5, "hmac(md5)", 16, FALSE, },
+ {PRF_HMAC_SHA2_384, "hmac(sha384)", 48, FALSE, },
+ {PRF_HMAC_SHA2_512, "hmac(sha512)", 64, FALSE, },
+ {PRF_AES128_XCBC, "xcbc(aes)", 16, TRUE, },
+ {PRF_CAMELLIA128_XCBC, "xcbc(camellia)", 16, TRUE, },
+};
+
+/**
+ * See header.
+ */
+void af_alg_prf_probe()
+{
+ af_alg_ops_t *ops;
+ int i;
+
+ for (i = 0; i < countof(algs); i++)
+ {
+ ops = af_alg_ops_create("hash", algs[i].name);
+ if (ops)
+ {
+ ops->destroy(ops);
+ lib->crypto->add_prf(lib->crypto, algs[i].id, af_alg_plugin_name,
+ (prf_constructor_t)af_alg_prf_create);
+ }
+ }
+}
+
+/**
+ * Get the kernel algorithm string and block size for our identifier
+ */
+static size_t lookup_alg(integrity_algorithm_t algo, char **name, bool *xcbc)
+{
+ int i;
+
+ for (i = 0; i < countof(algs); i++)
+ {
+ if (algs[i].id == algo)
+ {
+ *name = algs[i].name;
+ *xcbc = algs[i].xcbc;
+ return algs[i].block_size;
+ }
+ }
+ return 0;
+}
+
+METHOD(prf_t, get_bytes, void,
+ private_af_alg_prf_t *this, chunk_t seed, u_int8_t *buffer)
+{
+ this->ops->hash(this->ops, seed, buffer, this->block_size);
+}
+
+METHOD(prf_t, allocate_bytes, void,
+ private_af_alg_prf_t *this, chunk_t seed, chunk_t *chunk)
+{
+ if (chunk)
+ {
+ *chunk = chunk_alloc(this->block_size);
+ get_bytes(this, seed, chunk->ptr);
+ }
+ else
+ {
+ get_bytes(this, seed, NULL);
+ }
+}
+
+METHOD(prf_t, get_block_size, size_t,
+ private_af_alg_prf_t *this)
+{
+ return this->block_size;
+}
+
+METHOD(prf_t, get_key_size, size_t,
+ private_af_alg_prf_t *this)
+{
+ return this->block_size;
+}
+
+METHOD(prf_t, set_key, void,
+ private_af_alg_prf_t *this, chunk_t key)
+{
+ char buf[this->block_size];
+
+ if (this->xcbc)
+ {
+ /* The kernel currently does not support variable length XCBC keys,
+ * do RFC4434 key padding/reduction manually. */
+ if (key.len < this->block_size)
+ {
+ memset(buf, 0, this->block_size);
+ memcpy(buf, key.ptr, key.len);
+ key = chunk_from_thing(buf);
+ }
+ else if (key.len > this->block_size)
+ {
+ memset(buf, 0, this->block_size);
+ this->ops->set_key(this->ops, chunk_from_thing(buf));
+ this->ops->hash(this->ops, key, buf, this->block_size);
+ key = chunk_from_thing(buf);
+ }
+ }
+ this->ops->set_key(this->ops, key);
+}
+
+METHOD(prf_t, destroy, void,
+ private_af_alg_prf_t *this)
+{
+ this->ops->destroy(this->ops);
+ free(this);
+}
+
+/*
+ * Described in header.
+ */
+af_alg_prf_t *af_alg_prf_create(pseudo_random_function_t algo)
+{
+ private_af_alg_prf_t *this;
+ size_t block_size;
+ bool xcbc;
+ char *name;
+
+ block_size = lookup_alg(algo, &name, &xcbc);
+ if (!block_size)
+ { /* not supported by kernel */
+ return NULL;
+ }
+
+ INIT(this,
+ .public = {
+ .prf = {
+ .get_bytes = _get_bytes,
+ .allocate_bytes = _allocate_bytes,
+ .get_block_size = _get_block_size,
+ .get_key_size = _get_key_size,
+ .set_key = _set_key,
+ .destroy = _destroy,
+ },
+ },
+ .ops = af_alg_ops_create("hash", name),
+ .block_size = block_size,
+ .xcbc = xcbc,
+ );
+ if (!this->ops)
+ {
+ free(this);
+ return NULL;
+ }
+ return &this->public;
+}
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_prf.h b/src/libstrongswan/plugins/af_alg/af_alg_prf.h
new file mode 100644
index 000000000..a3dea5649
--- /dev/null
+++ b/src/libstrongswan/plugins/af_alg/af_alg_prf.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup af_alg_prf af_alg_prf
+ * @{ @ingroup af_alg
+ */
+
+#ifndef AF_ALG_PRF_H_
+#define AF_ALG_PRF_H_
+
+typedef struct af_alg_prf_t af_alg_prf_t;
+
+#include <crypto/prfs/prf.h>
+
+/**
+ * Implementation of PRFs using AF_ALG.
+ */
+struct af_alg_prf_t {
+
+ /**
+ * Implements prf_t interface.
+ */
+ prf_t prf;
+};
+
+/**
+ * Creates a new af_alg_prf_t object.
+ *
+ * @param algo algorithm to implement
+ * @return af_alg_prf_t object, NULL if hash not supported
+ */
+af_alg_prf_t *af_alg_prf_create(pseudo_random_function_t algo);
+
+/**
+ * Probe algorithms and register af_alg_prf_create().
+ */
+void af_alg_prf_probe();
+
+#endif /** AF_ALG_PRF_H_ @}*/
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_signer.c b/src/libstrongswan/plugins/af_alg/af_alg_signer.c
new file mode 100644
index 000000000..3d6f907bf
--- /dev/null
+++ b/src/libstrongswan/plugins/af_alg/af_alg_signer.c
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include "af_alg_signer.h"
+#include "af_alg_ops.h"
+
+typedef struct private_af_alg_signer_t private_af_alg_signer_t;
+
+/**
+ * Private data structure with signing context.
+ */
+struct private_af_alg_signer_t {
+
+ /**
+ * Public interface of af_alg_signer_t.
+ */
+ af_alg_signer_t public;
+
+ /**
+ * AF_ALG operations
+ */
+ af_alg_ops_t *ops;
+
+ /**
+ * Size of the truncated signature
+ */
+ size_t block_size;
+
+ /**
+ * Default key size
+ */
+ size_t key_size;
+};
+
+/**
+ * Algorithm database
+ */
+static struct {
+ integrity_algorithm_t id;
+ char *name;
+ size_t block_size;
+ size_t key_size;
+} algs[] = {
+ {AUTH_HMAC_SHA1_96, "hmac(sha1)", 12, 20, },
+ {AUTH_HMAC_SHA1_128, "hmac(sha1)", 16, 20, },
+ {AUTH_HMAC_SHA1_160, "hmac(sha1)", 20, 20, },
+ {AUTH_HMAC_SHA2_256_96, "hmac(sha256)", 12, 32, },
+ {AUTH_HMAC_SHA2_256_128, "hmac(sha256)", 16, 32, },
+ {AUTH_HMAC_MD5_96, "hmac(md5)", 12, 16, },
+ {AUTH_HMAC_MD5_128, "hmac(md5)", 16, 16, },
+ {AUTH_HMAC_SHA2_256_256, "hmac(sha384)", 32, 32, },
+ {AUTH_HMAC_SHA2_384_192, "hmac(sha384)", 24, 48, },
+ {AUTH_HMAC_SHA2_384_384, "hmac(sha384)", 48, 48, },
+ {AUTH_HMAC_SHA2_512_256, "hmac(sha512)", 32, 64, },
+ {AUTH_AES_XCBC_96, "xcbc(aes)", 12, 16, },
+ {AUTH_CAMELLIA_XCBC_96, "xcbc(camellia)", 12, 16, },
+};
+
+/**
+ * See header.
+ */
+void af_alg_signer_probe()
+{
+ af_alg_ops_t *ops;
+ int i;
+
+ for (i = 0; i < countof(algs); i++)
+ {
+ ops = af_alg_ops_create("hash", algs[i].name);
+ if (ops)
+ {
+ ops->destroy(ops);
+ lib->crypto->add_signer(lib->crypto, algs[i].id, af_alg_plugin_name,
+ (signer_constructor_t)af_alg_signer_create);
+ }
+ }
+}
+
+/**
+ * Get the kernel algorithm string and block/key size for our identifier
+ */
+static size_t lookup_alg(integrity_algorithm_t algo, char **name,
+ size_t *key_size)
+{
+ int i;
+
+ for (i = 0; i < countof(algs); i++)
+ {
+ if (algs[i].id == algo)
+ {
+ *name = algs[i].name;
+ *key_size = algs[i].key_size;
+ return algs[i].block_size;
+ }
+ }
+ return 0;
+}
+
+METHOD(signer_t, get_signature, void,
+ private_af_alg_signer_t *this, chunk_t data, u_int8_t *buffer)
+{
+ this->ops->hash(this->ops, data, buffer, this->block_size);
+}
+
+METHOD(signer_t, allocate_signature, void,
+ private_af_alg_signer_t *this, chunk_t data, chunk_t *chunk)
+{
+ if (chunk)
+ {
+ *chunk = chunk_alloc(this->block_size);
+ get_signature(this, data, chunk->ptr);
+ }
+ else
+ {
+ get_signature(this, data, NULL);
+ }
+}
+
+METHOD(signer_t, verify_signature, bool,
+ private_af_alg_signer_t *this, chunk_t data, chunk_t signature)
+{
+ char sig[this->block_size];
+
+ if (signature.len != this->block_size)
+ {
+ return FALSE;
+ }
+ get_signature(this, data, sig);
+ return memeq(signature.ptr, sig, signature.len);
+}
+
+METHOD(signer_t, get_key_size, size_t,
+ private_af_alg_signer_t *this)
+{
+ return this->key_size;
+}
+
+METHOD(signer_t, get_block_size, size_t,
+ private_af_alg_signer_t *this)
+{
+ return this->block_size;
+}
+
+METHOD(signer_t, set_key, void,
+ private_af_alg_signer_t *this, chunk_t key)
+{
+ this->ops->set_key(this->ops, key);
+}
+
+METHOD(signer_t, destroy, void,
+ private_af_alg_signer_t *this)
+{
+ this->ops->destroy(this->ops);
+ free(this);
+}
+
+/*
+ * Described in header
+ */
+af_alg_signer_t *af_alg_signer_create(integrity_algorithm_t algo)
+{
+ private_af_alg_signer_t *this;
+ size_t block_size, key_size;
+ char *name;
+
+ block_size = lookup_alg(algo, &name, &key_size);
+ if (!block_size)
+ { /* not supported by kernel */
+ return NULL;
+ }
+
+ INIT(this,
+ .public = {
+ .signer = {
+ .get_signature = _get_signature,
+ .allocate_signature = _allocate_signature,
+ .verify_signature = _verify_signature,
+ .get_key_size = _get_key_size,
+ .get_block_size = _get_block_size,
+ .set_key = _set_key,
+ .destroy = _destroy,
+ },
+ },
+ .ops = af_alg_ops_create("hash", name),
+ .block_size = block_size,
+ .key_size = key_size,
+ );
+ if (!this->ops)
+ {
+ free(this);
+ return NULL;
+ }
+ return &this->public;
+}
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_signer.h b/src/libstrongswan/plugins/af_alg/af_alg_signer.h
new file mode 100644
index 000000000..b1d90707f
--- /dev/null
+++ b/src/libstrongswan/plugins/af_alg/af_alg_signer.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup af_alg_signer af_alg_signer
+ * @{ @ingroup af_alg
+ */
+
+#ifndef AF_ALG_SIGNER_H_
+#define AF_ALG_SIGNER_H_
+
+typedef struct af_alg_signer_t af_alg_signer_t;
+
+#include <crypto/signers/signer.h>
+
+/**
+ * Implementation of signers using AF_ALG.
+ */
+struct af_alg_signer_t {
+
+ /**
+ * Implements signer_t interface.
+ */
+ signer_t signer;
+};
+
+/**
+ * Creates a new af_alg_signer_t.
+ *
+ * @param algo algorithm to implement
+ * @return af_alg_signer_t, NULL if not supported
+ */
+af_alg_signer_t *af_alg_signer_create(integrity_algorithm_t algo);
+
+/**
+ * Probe algorithms and register af_alg_signer_create().
+ */
+void af_alg_signer_probe();
+
+#endif /** AF_ALG_SIGNER_H_ @}*/
diff --git a/src/libstrongswan/plugins/agent/Makefile.in b/src/libstrongswan/plugins/agent/Makefile.in
index 9f65f4ffb..1a3533f03 100644
--- a/src/libstrongswan/plugins/agent/Makefile.in
+++ b/src/libstrongswan/plugins/agent/Makefile.in
@@ -221,9 +221,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -262,6 +260,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/blowfish/Makefile.in b/src/libstrongswan/plugins/blowfish/Makefile.in
index d310843ac..251722f60 100644
--- a/src/libstrongswan/plugins/blowfish/Makefile.in
+++ b/src/libstrongswan/plugins/blowfish/Makefile.in
@@ -223,9 +223,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -264,6 +262,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/blowfish/blowfish_plugin.c b/src/libstrongswan/plugins/blowfish/blowfish_plugin.c
index 6ab093d7b..5232eca28 100644
--- a/src/libstrongswan/plugins/blowfish/blowfish_plugin.c
+++ b/src/libstrongswan/plugins/blowfish/blowfish_plugin.c
@@ -19,6 +19,8 @@
#include <library.h>
#include "blowfish_crypter.h"
+static const char *plugin_name = "blowfish";
+
typedef struct private_blowfish_plugin_t private_blowfish_plugin_t;
/**
@@ -55,7 +57,7 @@ plugin_t *blowfish_plugin_create()
},
);
- lib->crypto->add_crypter(lib->crypto, ENCR_BLOWFISH,
+ lib->crypto->add_crypter(lib->crypto, ENCR_BLOWFISH, plugin_name,
(crypter_constructor_t)blowfish_crypter_create);
return &this->public.plugin;
diff --git a/src/libstrongswan/plugins/ccm/Makefile.in b/src/libstrongswan/plugins/ccm/Makefile.in
index 017d75c48..371e5b2f4 100644
--- a/src/libstrongswan/plugins/ccm/Makefile.in
+++ b/src/libstrongswan/plugins/ccm/Makefile.in
@@ -219,9 +219,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -260,6 +258,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/ccm/ccm_plugin.c b/src/libstrongswan/plugins/ccm/ccm_plugin.c
index 5fc3b14d7..a4c89b548 100644
--- a/src/libstrongswan/plugins/ccm/ccm_plugin.c
+++ b/src/libstrongswan/plugins/ccm/ccm_plugin.c
@@ -19,6 +19,8 @@
#include "ccm_aead.h"
+static const char *plugin_name = "ccm";
+
typedef struct private_ccm_plugin_t private_ccm_plugin_t;
/**
@@ -47,23 +49,34 @@ METHOD(plugin_t, destroy, void,
plugin_t *ccm_plugin_create()
{
private_ccm_plugin_t *this;
+ crypter_t *crypter;
INIT(this,
.public.plugin.destroy = _destroy,
);
- lib->crypto->add_aead(lib->crypto, ENCR_AES_CCM_ICV8,
- (aead_constructor_t)ccm_aead_create);
- lib->crypto->add_aead(lib->crypto, ENCR_AES_CCM_ICV12,
- (aead_constructor_t)ccm_aead_create);
- lib->crypto->add_aead(lib->crypto, ENCR_AES_CCM_ICV16,
- (aead_constructor_t)ccm_aead_create);
- lib->crypto->add_aead(lib->crypto, ENCR_CAMELLIA_CCM_ICV8,
- (aead_constructor_t)ccm_aead_create);
- lib->crypto->add_aead(lib->crypto, ENCR_CAMELLIA_CCM_ICV12,
- (aead_constructor_t)ccm_aead_create);
- lib->crypto->add_aead(lib->crypto, ENCR_CAMELLIA_CCM_ICV16,
- (aead_constructor_t)ccm_aead_create);
+ crypter = lib->crypto->create_crypter(lib->crypto, ENCR_AES_CBC, 0);
+ if (crypter)
+ {
+ crypter->destroy(crypter);
+ lib->crypto->add_aead(lib->crypto, ENCR_AES_CCM_ICV8, plugin_name,
+ (aead_constructor_t)ccm_aead_create);
+ lib->crypto->add_aead(lib->crypto, ENCR_AES_CCM_ICV12, plugin_name,
+ (aead_constructor_t)ccm_aead_create);
+ lib->crypto->add_aead(lib->crypto, ENCR_AES_CCM_ICV16, plugin_name,
+ (aead_constructor_t)ccm_aead_create);
+ }
+ crypter = lib->crypto->create_crypter(lib->crypto, ENCR_CAMELLIA_CBC, 0);
+ if (crypter)
+ {
+ crypter->destroy(crypter);
+ lib->crypto->add_aead(lib->crypto, ENCR_CAMELLIA_CCM_ICV8, plugin_name,
+ (aead_constructor_t)ccm_aead_create);
+ lib->crypto->add_aead(lib->crypto, ENCR_CAMELLIA_CCM_ICV12, plugin_name,
+ (aead_constructor_t)ccm_aead_create);
+ lib->crypto->add_aead(lib->crypto, ENCR_CAMELLIA_CCM_ICV16, plugin_name,
+ (aead_constructor_t)ccm_aead_create);
+ }
return &this->public.plugin;
}
diff --git a/src/libstrongswan/plugins/constraints/Makefile.am b/src/libstrongswan/plugins/constraints/Makefile.am
new file mode 100644
index 000000000..d80d39a2d
--- /dev/null
+++ b/src/libstrongswan/plugins/constraints/Makefile.am
@@ -0,0 +1,16 @@
+
+INCLUDES = -I$(top_srcdir)/src/libstrongswan
+
+AM_CFLAGS = -rdynamic
+
+if MONOLITHIC
+noinst_LTLIBRARIES = libstrongswan-constraints.la
+else
+plugin_LTLIBRARIES = libstrongswan-constraints.la
+endif
+
+libstrongswan_constraints_la_SOURCES = \
+ constraints_plugin.h constraints_plugin.c \
+ constraints_validator.h constraints_validator.c
+
+libstrongswan_constraints_la_LDFLAGS = -module -avoid-version
diff --git a/src/libstrongswan/plugins/constraints/Makefile.in b/src/libstrongswan/plugins/constraints/Makefile.in
new file mode 100644
index 000000000..382bfef98
--- /dev/null
+++ b/src/libstrongswan/plugins/constraints/Makefile.in
@@ -0,0 +1,604 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/libstrongswan/plugins/constraints
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/config/libtool.m4 \
+ $(top_srcdir)/m4/config/ltoptions.m4 \
+ $(top_srcdir)/m4/config/ltsugar.m4 \
+ $(top_srcdir)/m4/config/ltversion.m4 \
+ $(top_srcdir)/m4/config/lt~obsolete.m4 \
+ $(top_srcdir)/m4/macros/with.m4 \
+ $(top_srcdir)/m4/macros/enable-disable.m4 \
+ $(top_srcdir)/m4/macros/add-plugin.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(plugindir)"
+LTLIBRARIES = $(noinst_LTLIBRARIES) $(plugin_LTLIBRARIES)
+libstrongswan_constraints_la_LIBADD =
+am_libstrongswan_constraints_la_OBJECTS = constraints_plugin.lo \
+ constraints_validator.lo
+libstrongswan_constraints_la_OBJECTS = \
+ $(am_libstrongswan_constraints_la_OBJECTS)
+libstrongswan_constraints_la_LINK = $(LIBTOOL) --tag=CC \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
+ $(AM_CFLAGS) $(CFLAGS) $(libstrongswan_constraints_la_LDFLAGS) \
+ $(LDFLAGS) -o $@
+@MONOLITHIC_FALSE@am_libstrongswan_constraints_la_rpath = -rpath \
+@MONOLITHIC_FALSE@ $(plugindir)
+@MONOLITHIC_TRUE@am_libstrongswan_constraints_la_rpath =
+DEFAULT_INCLUDES = -I.@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libstrongswan_constraints_la_SOURCES)
+DIST_SOURCES = $(libstrongswan_constraints_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BTLIB = @BTLIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLIB = @DLLIB@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GPERF = @GPERF@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MYSQLCFLAG = @MYSQLCFLAG@
+MYSQLCONFIG = @MYSQLCONFIG@
+MYSQLLIB = @MYSQLLIB@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PTHREADLIB = @PTHREADLIB@
+RANLIB = @RANLIB@
+RTLIB = @RTLIB@
+RUBY = @RUBY@
+RUBYINCLUDE = @RUBYINCLUDE@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOCKLIB = @SOCKLIB@
+STRIP = @STRIP@
+VERSION = @VERSION@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+c_plugins = @c_plugins@
+datadir = @datadir@
+datarootdir = @datarootdir@
+dbusservicedir = @dbusservicedir@
+default_pkcs11 = @default_pkcs11@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+gtk_CFLAGS = @gtk_CFLAGS@
+gtk_LIBS = @gtk_LIBS@
+h_plugins = @h_plugins@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+ipsecdir = @ipsecdir@
+ipsecgroup = @ipsecgroup@
+ipsecuser = @ipsecuser@
+libcharon_plugins = @libcharon_plugins@
+libdir = @libdir@
+libexecdir = @libexecdir@
+linux_headers = @linux_headers@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+maemo_CFLAGS = @maemo_CFLAGS@
+maemo_LIBS = @maemo_LIBS@
+manager_plugins = @manager_plugins@
+mandir = @mandir@
+medsrv_plugins = @medsrv_plugins@
+mkdir_p = @mkdir_p@
+nm_CFLAGS = @nm_CFLAGS@
+nm_LIBS = @nm_LIBS@
+nm_ca_dir = @nm_ca_dir@
+oldincludedir = @oldincludedir@
+openac_plugins = @openac_plugins@
+p_plugins = @p_plugins@
+pdfdir = @pdfdir@
+piddir = @piddir@
+pki_plugins = @pki_plugins@
+plugindir = @plugindir@
+pluto_plugins = @pluto_plugins@
+pool_plugins = @pool_plugins@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+random_device = @random_device@
+resolv_conf = @resolv_conf@
+routing_table = @routing_table@
+routing_table_prio = @routing_table_prio@
+s_plugins = @s_plugins@
+sbindir = @sbindir@
+scepclient_plugins = @scepclient_plugins@
+scripts_plugins = @scripts_plugins@
+sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
+srcdir = @srcdir@
+strongswan_conf = @strongswan_conf@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+urandom_device = @urandom_device@
+xml_CFLAGS = @xml_CFLAGS@
+xml_LIBS = @xml_LIBS@
+INCLUDES = -I$(top_srcdir)/src/libstrongswan
+AM_CFLAGS = -rdynamic
+@MONOLITHIC_TRUE@noinst_LTLIBRARIES = libstrongswan-constraints.la
+@MONOLITHIC_FALSE@plugin_LTLIBRARIES = libstrongswan-constraints.la
+libstrongswan_constraints_la_SOURCES = \
+ constraints_plugin.h constraints_plugin.c \
+ constraints_validator.h constraints_validator.c
+
+libstrongswan_constraints_la_LDFLAGS = -module -avoid-version
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/libstrongswan/plugins/constraints/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/libstrongswan/plugins/constraints/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(plugindir)" || $(MKDIR_P) "$(DESTDIR)$(plugindir)"
+ @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \
+ }
+
+uninstall-pluginLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \
+ done
+
+clean-pluginLTLIBRARIES:
+ -test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES)
+ @list='$(plugin_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libstrongswan-constraints.la: $(libstrongswan_constraints_la_OBJECTS) $(libstrongswan_constraints_la_DEPENDENCIES)
+ $(libstrongswan_constraints_la_LINK) $(am_libstrongswan_constraints_la_rpath) $(libstrongswan_constraints_la_OBJECTS) $(libstrongswan_constraints_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/constraints_plugin.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/constraints_validator.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(plugindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ clean-pluginLTLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pluginLTLIBRARIES
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pluginLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLTLIBRARIES clean-pluginLTLIBRARIES \
+ ctags distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-pluginLTLIBRARIES install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am \
+ uninstall-pluginLTLIBRARIES
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/libstrongswan/plugins/constraints/constraints_plugin.c b/src/libstrongswan/plugins/constraints/constraints_plugin.c
new file mode 100644
index 000000000..1c3f0c835
--- /dev/null
+++ b/src/libstrongswan/plugins/constraints/constraints_plugin.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include "constraints_plugin.h"
+
+#include <library.h>
+#include "constraints_validator.h"
+
+typedef struct private_constraints_plugin_t private_constraints_plugin_t;
+
+/**
+ * private data of constraints_plugin
+ */
+struct private_constraints_plugin_t {
+
+ /**
+ * public functions
+ */
+ constraints_plugin_t public;
+
+ /**
+ * Validator implementation instance.
+ */
+ constraints_validator_t *validator;
+};
+
+METHOD(plugin_t, destroy, void,
+ private_constraints_plugin_t *this)
+{
+ lib->credmgr->remove_validator(lib->credmgr, &this->validator->validator);
+ this->validator->destroy(this->validator);
+ free(this);
+}
+
+/*
+ * see header file
+ */
+plugin_t *constraints_plugin_create()
+{
+ private_constraints_plugin_t *this;
+
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ .validator = constraints_validator_create(),
+ );
+ lib->credmgr->add_validator(lib->credmgr, &this->validator->validator);
+
+ return &this->public.plugin;
+}
diff --git a/src/libstrongswan/plugins/constraints/constraints_plugin.h b/src/libstrongswan/plugins/constraints/constraints_plugin.h
new file mode 100644
index 000000000..7042a4d92
--- /dev/null
+++ b/src/libstrongswan/plugins/constraints/constraints_plugin.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup constraints constraints
+ * @ingroup plugins
+ *
+ * @defgroup constraints_plugin constraints_plugin
+ * @{ @ingroup constraints
+ */
+
+#ifndef CONSTRAINTS_PLUGIN_H_
+#define CONSTRAINTS_PLUGIN_H_
+
+#include <plugins/plugin.h>
+
+typedef struct constraints_plugin_t constraints_plugin_t;
+
+/**
+ * Advanced X509 constraint checking.
+ */
+struct constraints_plugin_t {
+
+ /**
+ * Implements plugin_t. interface.
+ */
+ plugin_t plugin;
+};
+
+#endif /** CONSTRAINTS_PLUGIN_H_ @}*/
diff --git a/src/libstrongswan/plugins/constraints/constraints_validator.c b/src/libstrongswan/plugins/constraints/constraints_validator.c
new file mode 100644
index 000000000..b54d813df
--- /dev/null
+++ b/src/libstrongswan/plugins/constraints/constraints_validator.c
@@ -0,0 +1,578 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include "constraints_validator.h"
+
+#include <debug.h>
+#include <asn1/asn1.h>
+#include <utils/linked_list.h>
+#include <credentials/certificates/x509.h>
+
+typedef struct private_constraints_validator_t private_constraints_validator_t;
+
+/**
+ * Private data of an constraints_validator_t object.
+ */
+struct private_constraints_validator_t {
+
+ /**
+ * Public constraints_validator_t interface.
+ */
+ constraints_validator_t public;
+};
+
+/**
+ * Check pathlen constraint of issuer certificate
+ */
+static bool check_pathlen(x509_t *issuer, int pathlen)
+{
+ u_int pathlen_constraint;
+
+ pathlen_constraint = issuer->get_constraint(issuer, X509_PATH_LEN);
+ if (pathlen_constraint != X509_NO_CONSTRAINT &&
+ pathlen > pathlen_constraint)
+ {
+ DBG1(DBG_CFG, "path length of %d violates constraint of %d",
+ pathlen, pathlen_constraint);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
+ * Check if a FQDN/RFC822 constraint matches (suffix match)
+ */
+static bool suffix_matches(identification_t *constraint, identification_t *id)
+{
+ chunk_t c, i;
+
+ c = constraint->get_encoding(constraint);
+ i = id->get_encoding(id);
+
+ return i.len >= c.len && chunk_equals(c, chunk_skip(i, i.len - c.len));
+}
+
+/**
+ * Check if a DN constraint matches (RDN prefix match)
+ */
+static bool dn_matches(identification_t *constraint, identification_t *id)
+{
+ enumerator_t *ec, *ei;
+ id_part_t pc, pi;
+ chunk_t cc, ci;
+ bool match = TRUE;
+
+ ec = constraint->create_part_enumerator(constraint);
+ ei = id->create_part_enumerator(id);
+ while (ec->enumerate(ec, &pc, &cc))
+ {
+ if (!ei->enumerate(ei, &pi, &ci) ||
+ pi != pc || !chunk_equals(cc, ci))
+ {
+ match = FALSE;
+ break;
+ }
+ }
+ ec->destroy(ec);
+ ei->destroy(ei);
+
+ return match;
+}
+
+/**
+ * Check if a certificate matches to a NameConstraint
+ */
+static bool name_constraint_matches(identification_t *constraint,
+ certificate_t *cert, bool permitted)
+{
+ x509_t *x509 = (x509_t*)cert;
+ enumerator_t *enumerator;
+ identification_t *id;
+ id_type_t type;
+ bool matches = permitted;
+
+ type = constraint->get_type(constraint);
+ if (type == ID_DER_ASN1_DN)
+ {
+ matches = dn_matches(constraint, cert->get_subject(cert));
+ if (matches != permitted)
+ {
+ return matches;
+ }
+ }
+
+ enumerator = x509->create_subjectAltName_enumerator(x509);
+ while (enumerator->enumerate(enumerator, &id))
+ {
+ if (id->get_type(id) == type)
+ {
+ switch (type)
+ {
+ case ID_FQDN:
+ case ID_RFC822_ADDR:
+ matches = suffix_matches(constraint, id);
+ break;
+ case ID_DER_ASN1_DN:
+ matches = dn_matches(constraint, id);
+ break;
+ default:
+ DBG1(DBG_CFG, "%N NameConstraint matching not implemented",
+ id_type_names, type);
+ matches = FALSE;
+ break;
+ }
+ }
+ if (matches != permitted)
+ {
+ break;
+ }
+ }
+ enumerator->destroy(enumerator);
+
+ return matches;
+}
+
+/**
+ * Check if a permitted or excluded NameConstraint has been inherited to sub-CA
+ */
+static bool name_constraint_inherited(identification_t *constraint,
+ x509_t *x509, bool permitted)
+{
+ enumerator_t *enumerator;
+ identification_t *id;
+ bool inherited = FALSE;
+ id_type_t type;
+
+ if (!(x509->get_flags(x509) & X509_CA))
+ { /* not a sub-CA, not required */
+ return TRUE;
+ }
+
+ type = constraint->get_type(constraint);
+ enumerator = x509->create_name_constraint_enumerator(x509, permitted);
+ while (enumerator->enumerate(enumerator, &id))
+ {
+ if (id->get_type(id) == type)
+ {
+ switch (type)
+ {
+ case ID_FQDN:
+ case ID_RFC822_ADDR:
+ if (permitted)
+ { /* permitted constraint can be narrowed */
+ inherited = suffix_matches(constraint, id);
+ }
+ else
+ { /* excluded constraint can be widened */
+ inherited = suffix_matches(id, constraint);
+ }
+ break;
+ case ID_DER_ASN1_DN:
+ if (permitted)
+ {
+ inherited = dn_matches(constraint, id);
+ }
+ else
+ {
+ inherited = dn_matches(id, constraint);
+ }
+ break;
+ default:
+ DBG1(DBG_CFG, "%N NameConstraint matching not implemented",
+ id_type_names, type);
+ inherited = FALSE;
+ break;
+ }
+ }
+ if (inherited)
+ {
+ break;
+ }
+ }
+ enumerator->destroy(enumerator);
+ return inherited;
+}
+
+/**
+ * Check name constraints
+ */
+static bool check_name_constraints(certificate_t *subject, x509_t *issuer)
+{
+ enumerator_t *enumerator;
+ identification_t *constraint;
+
+ enumerator = issuer->create_name_constraint_enumerator(issuer, TRUE);
+ while (enumerator->enumerate(enumerator, &constraint))
+ {
+ if (!name_constraint_matches(constraint, subject, TRUE))
+ {
+ DBG1(DBG_CFG, "certificate '%Y' does not match permitted name "
+ "constraint '%Y'", subject->get_subject(subject), constraint);
+ enumerator->destroy(enumerator);
+ return FALSE;
+ }
+ if (!name_constraint_inherited(constraint, (x509_t*)subject, TRUE))
+ {
+ DBG1(DBG_CFG, "intermediate CA '%Y' does not inherit permitted name "
+ "constraint '%Y'", subject->get_subject(subject), constraint);
+ enumerator->destroy(enumerator);
+ return FALSE;
+ }
+ }
+ enumerator->destroy(enumerator);
+
+ enumerator = issuer->create_name_constraint_enumerator(issuer, FALSE);
+ while (enumerator->enumerate(enumerator, &constraint))
+ {
+ if (name_constraint_matches(constraint, subject, FALSE))
+ {
+ DBG1(DBG_CFG, "certificate '%Y' matches excluded name "
+ "constraint '%Y'", subject->get_subject(subject), constraint);
+ enumerator->destroy(enumerator);
+ return FALSE;
+ }
+ if (!name_constraint_inherited(constraint, (x509_t*)subject, FALSE))
+ {
+ DBG1(DBG_CFG, "intermediate CA '%Y' does not inherit excluded name "
+ "constraint '%Y'", subject->get_subject(subject), constraint);
+ enumerator->destroy(enumerator);
+ return FALSE;
+ }
+ }
+ enumerator->destroy(enumerator);
+ return TRUE;
+}
+
+/**
+ * Special OID for anyPolicy
+ */
+static chunk_t any_policy = chunk_from_chars(0x55,0x1d,0x20,0x00);
+
+/**
+ * Check if an issuer certificate has a given policy OID
+ */
+static bool has_policy(x509_t *issuer, chunk_t oid)
+{
+ x509_policy_mapping_t *mapping;
+ x509_cert_policy_t *policy;
+ enumerator_t *enumerator;
+
+ enumerator = issuer->create_cert_policy_enumerator(issuer);
+ while (enumerator->enumerate(enumerator, &policy))
+ {
+ if (chunk_equals(oid, policy->oid) ||
+ chunk_equals(any_policy, policy->oid))
+ {
+ enumerator->destroy(enumerator);
+ return TRUE;
+ }
+ }
+ enumerator->destroy(enumerator);
+
+ /* fall back to a mapped policy */
+ enumerator = issuer->create_policy_mapping_enumerator(issuer);
+ while (enumerator->enumerate(enumerator, &mapping))
+ {
+ if (chunk_equals(mapping->subject, oid))
+ {
+ enumerator->destroy(enumerator);
+ return TRUE;
+ }
+ }
+ enumerator->destroy(enumerator);
+ return FALSE;
+}
+
+/**
+ * Check certificatePolicies.
+ */
+static bool check_policy(x509_t *subject, x509_t *issuer, bool check,
+ auth_cfg_t *auth)
+{
+ certificate_t *cert = (certificate_t*)subject;
+ x509_policy_mapping_t *mapping;
+ x509_cert_policy_t *policy;
+ enumerator_t *enumerator;
+ char *oid;
+
+ /* verify if policyMappings in subject are valid */
+ enumerator = subject->create_policy_mapping_enumerator(subject);
+ while (enumerator->enumerate(enumerator, &mapping))
+ {
+ if (!has_policy(issuer, mapping->issuer))
+ {
+ oid = asn1_oid_to_string(mapping->issuer);
+ DBG1(DBG_CFG, "certificate '%Y' maps policy from %s, but issuer "
+ "misses it", cert->get_subject(cert), oid);
+ free(oid);
+ enumerator->destroy(enumerator);
+ return FALSE;
+ }
+ }
+ enumerator->destroy(enumerator);
+
+ if (check)
+ {
+ enumerator = subject->create_cert_policy_enumerator(subject);
+ while (enumerator->enumerate(enumerator, &policy))
+ {
+ if (!has_policy(issuer, policy->oid))
+ {
+ oid = asn1_oid_to_string(policy->oid);
+ DBG1(DBG_CFG, "policy %s missing in issuing certificate '%Y'",
+ oid, cert->get_issuer(cert));
+ free(oid);
+ enumerator->destroy(enumerator);
+ return FALSE;
+ }
+ if (auth)
+ {
+ oid = asn1_oid_to_string(policy->oid);
+ if (oid)
+ {
+ auth->add(auth, AUTH_RULE_CERT_POLICY, oid);
+ }
+ }
+ }
+ enumerator->destroy(enumerator);
+ }
+
+ return TRUE;
+}
+
+/**
+ * Check len certificates in trustchain for inherited policies
+ */
+static bool has_policy_chain(linked_list_t *chain, x509_t *subject, int len)
+{
+ enumerator_t *enumerator;
+ x509_t *issuer;
+ bool valid = TRUE;
+
+ enumerator = chain->create_enumerator(chain);
+ while (len-- > 0 && enumerator->enumerate(enumerator, &issuer))
+ {
+ if (!check_policy(subject, issuer, TRUE, NULL))
+ {
+ valid = FALSE;
+ break;
+ }
+ subject = issuer;
+ }
+ enumerator->destroy(enumerator);
+ return valid;
+}
+
+/**
+ * Check len certificates in trustchain to have no policyMappings
+ */
+static bool has_no_policy_mapping(linked_list_t *chain, int len)
+{
+ enumerator_t *enumerator, *mappings;
+ x509_policy_mapping_t *mapping;
+ certificate_t *cert;
+ x509_t *x509;
+ bool valid = TRUE;
+
+ enumerator = chain->create_enumerator(chain);
+ while (len-- > 0 && enumerator->enumerate(enumerator, &x509))
+ {
+ mappings = x509->create_policy_mapping_enumerator(x509);
+ valid = !mappings->enumerate(mappings, &mapping);
+ mappings->destroy(mappings);
+ if (!valid)
+ {
+ cert = (certificate_t*)x509;
+ DBG1(DBG_CFG, "found policyMapping in certificate '%Y', but "
+ "inhibitPolicyMapping in effect", cert->get_subject(cert));
+ break;
+ }
+ }
+ enumerator->destroy(enumerator);
+ return valid;
+}
+
+/**
+ * Check len certificates in trustchain to have no anyPolicies
+ */
+static bool has_no_any_policy(linked_list_t *chain, int len)
+{
+ enumerator_t *enumerator, *policies;
+ x509_cert_policy_t *policy;
+ certificate_t *cert;
+ x509_t *x509;
+ bool valid = TRUE;
+
+ enumerator = chain->create_enumerator(chain);
+ while (len-- > 0 && enumerator->enumerate(enumerator, &x509))
+ {
+ policies = x509->create_cert_policy_enumerator(x509);
+ while (policies->enumerate(policies, &policy))
+ {
+ if (chunk_equals(policy->oid, any_policy))
+ {
+ cert = (certificate_t*)x509;
+ DBG1(DBG_CFG, "found anyPolicy in certificate '%Y', but "
+ "inhibitAnyPolicy in effect", cert->get_subject(cert));
+ valid = FALSE;
+ break;
+ }
+ }
+ policies->destroy(policies);
+ }
+ enumerator->destroy(enumerator);
+ return valid;
+}
+
+/**
+ * Check requireExplicitPolicy and inhibitPolicyMapping constraints
+ */
+static bool check_policy_constraints(x509_t *issuer, u_int pathlen,
+ auth_cfg_t *auth)
+{
+ certificate_t *subject;
+ bool valid = TRUE;
+
+ subject = auth->get(auth, AUTH_RULE_SUBJECT_CERT);
+ if (subject)
+ {
+ if (subject->get_type(subject) == CERT_X509)
+ {
+ enumerator_t *enumerator;
+ linked_list_t *chain;
+ certificate_t *cert;
+ auth_rule_t rule;
+ x509_t *x509;
+ int len = 0;
+ u_int expl, inh;
+
+ /* prepare trustchain to validate */
+ chain = linked_list_create();
+ enumerator = auth->create_enumerator(auth);
+ while (enumerator->enumerate(enumerator, &rule, &cert))
+ {
+ if (rule == AUTH_RULE_IM_CERT &&
+ cert->get_type(cert) == CERT_X509)
+ {
+ chain->insert_last(chain, cert);
+ }
+ }
+ enumerator->destroy(enumerator);
+ chain->insert_last(chain, issuer);
+
+ /* search for requireExplicitPolicy constraints */
+ enumerator = chain->create_enumerator(chain);
+ while (enumerator->enumerate(enumerator, &x509))
+ {
+ expl = x509->get_constraint(x509, X509_REQUIRE_EXPLICIT_POLICY);
+ if (expl != X509_NO_CONSTRAINT)
+ {
+ if (!has_policy_chain(chain, (x509_t*)subject, len - expl))
+ {
+ valid = FALSE;
+ break;
+ }
+ }
+ len++;
+ }
+ enumerator->destroy(enumerator);
+
+ /* search for inhibitPolicyMapping/inhibitAnyPolicy constraints */
+ len = 0;
+ chain->insert_first(chain, subject);
+ enumerator = chain->create_enumerator(chain);
+ while (enumerator->enumerate(enumerator, &x509))
+ {
+ inh = x509->get_constraint(x509, X509_INHIBIT_POLICY_MAPPING);
+ if (inh != X509_NO_CONSTRAINT)
+ {
+ if (!has_no_policy_mapping(chain, len - inh))
+ {
+ valid = FALSE;
+ break;
+ }
+ }
+ inh = x509->get_constraint(x509, X509_INHIBIT_ANY_POLICY);
+ if (inh != X509_NO_CONSTRAINT)
+ {
+ if (!has_no_any_policy(chain, len - inh))
+ {
+ valid = FALSE;
+ break;
+ }
+ }
+ len++;
+ }
+ enumerator->destroy(enumerator);
+
+ chain->destroy(chain);
+ }
+ }
+ return valid;
+}
+
+METHOD(cert_validator_t, validate, bool,
+ private_constraints_validator_t *this, certificate_t *subject,
+ certificate_t *issuer, bool online, u_int pathlen, bool anchor,
+ auth_cfg_t *auth)
+{
+ if (issuer->get_type(issuer) == CERT_X509 &&
+ subject->get_type(subject) == CERT_X509)
+ {
+ if (!check_pathlen((x509_t*)issuer, pathlen))
+ {
+ return FALSE;
+ }
+ if (!check_name_constraints(subject, (x509_t*)issuer))
+ {
+ return FALSE;
+ }
+ if (!check_policy((x509_t*)subject, (x509_t*)issuer, !pathlen, auth))
+ {
+ return FALSE;
+ }
+ if (anchor)
+ {
+ if (!check_policy_constraints((x509_t*)issuer, pathlen, auth))
+ {
+ return FALSE;
+ }
+ }
+ }
+ return TRUE;
+}
+
+METHOD(constraints_validator_t, destroy, void,
+ private_constraints_validator_t *this)
+{
+ free(this);
+}
+
+/**
+ * See header
+ */
+constraints_validator_t *constraints_validator_create()
+{
+ private_constraints_validator_t *this;
+
+ INIT(this,
+ .public = {
+ .validator.validate = _validate,
+ .destroy = _destroy,
+ },
+ );
+
+ return &this->public;
+}
diff --git a/src/libstrongswan/plugins/constraints/constraints_validator.h b/src/libstrongswan/plugins/constraints/constraints_validator.h
new file mode 100644
index 000000000..44582d6c8
--- /dev/null
+++ b/src/libstrongswan/plugins/constraints/constraints_validator.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup constraints_validator constraints_validator
+ * @{ @ingroup constraints
+ */
+
+#ifndef CONSTRAINTS_VALIDATOR_H_
+#define CONSTRAINTS_VALIDATOR_H_
+
+#include <credentials/cert_validator.h>
+
+typedef struct constraints_validator_t constraints_validator_t;
+
+/**
+ * Certificate validator doing advanced X509 constraint checking.
+ */
+struct constraints_validator_t {
+
+ /**
+ * Implements cert_validator_t interface.
+ */
+ cert_validator_t validator;
+
+ /**
+ * Destroy a constraints_validator_t.
+ */
+ void (*destroy)(constraints_validator_t *this);
+};
+
+/**
+ * Create a constraints_validator instance.
+ */
+constraints_validator_t *constraints_validator_create();
+
+#endif /** CONSTRAINTS_VALIDATOR_H_ @}*/
diff --git a/src/libstrongswan/plugins/ctr/Makefile.in b/src/libstrongswan/plugins/ctr/Makefile.in
index b51f57113..2f6be07e2 100644
--- a/src/libstrongswan/plugins/ctr/Makefile.in
+++ b/src/libstrongswan/plugins/ctr/Makefile.in
@@ -219,9 +219,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -260,6 +258,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/ctr/ctr_plugin.c b/src/libstrongswan/plugins/ctr/ctr_plugin.c
index 5e47f23ec..9f1bf957f 100644
--- a/src/libstrongswan/plugins/ctr/ctr_plugin.c
+++ b/src/libstrongswan/plugins/ctr/ctr_plugin.c
@@ -19,6 +19,8 @@
#include "ctr_ipsec_crypter.h"
+static const char *plugin_name = "ctr";
+
typedef struct private_ctr_plugin_t private_ctr_plugin_t;
/**
@@ -47,6 +49,7 @@ METHOD(plugin_t, destroy, void,
plugin_t *ctr_plugin_create()
{
private_ctr_plugin_t *this;
+ crypter_t *crypter;
INIT(this,
.public = {
@@ -56,10 +59,19 @@ plugin_t *ctr_plugin_create()
},
);
- lib->crypto->add_crypter(lib->crypto, ENCR_AES_CTR,
- (crypter_constructor_t)ctr_ipsec_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_CAMELLIA_CTR,
- (crypter_constructor_t)ctr_ipsec_crypter_create);
-
+ crypter = lib->crypto->create_crypter(lib->crypto, ENCR_AES_CBC, 16);
+ if (crypter)
+ {
+ crypter->destroy(crypter);
+ lib->crypto->add_crypter(lib->crypto, ENCR_AES_CTR, plugin_name,
+ (crypter_constructor_t)ctr_ipsec_crypter_create);
+ }
+ crypter = lib->crypto->create_crypter(lib->crypto, ENCR_CAMELLIA_CBC, 16);
+ if (crypter)
+ {
+ crypter->destroy(crypter);
+ lib->crypto->add_crypter(lib->crypto, ENCR_CAMELLIA_CTR, plugin_name,
+ (crypter_constructor_t)ctr_ipsec_crypter_create);
+ }
return &this->public.plugin;
}
diff --git a/src/libstrongswan/plugins/curl/Makefile.in b/src/libstrongswan/plugins/curl/Makefile.in
index 9cc99063c..e61c73041 100644
--- a/src/libstrongswan/plugins/curl/Makefile.in
+++ b/src/libstrongswan/plugins/curl/Makefile.in
@@ -219,9 +219,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -260,6 +258,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/curl/curl_fetcher.c b/src/libstrongswan/plugins/curl/curl_fetcher.c
index 4835f6461..82e24e810 100644
--- a/src/libstrongswan/plugins/curl/curl_fetcher.c
+++ b/src/libstrongswan/plugins/curl/curl_fetcher.c
@@ -104,6 +104,7 @@ METHOD(fetcher_t, fetch, status_t,
METHOD(fetcher_t, set_option, bool,
private_curl_fetcher_t *this, fetcher_option_t option, ...)
{
+ bool supported = TRUE;
va_list args;
va_start(args, option);
@@ -115,7 +116,7 @@ METHOD(fetcher_t, set_option, bool,
curl_easy_setopt(this->curl, CURLOPT_POSTFIELDS, (char*)data.ptr);
curl_easy_setopt(this->curl, CURLOPT_POSTFIELDSIZE, data.len);
- return TRUE;
+ break;
}
case FETCH_REQUEST_TYPE:
{
@@ -124,30 +125,33 @@ METHOD(fetcher_t, set_option, bool,
snprintf(header, BUF_LEN, "Content-Type: %s", request_type);
this->headers = curl_slist_append(this->headers, header);
- return TRUE;
+ break;
}
case FETCH_REQUEST_HEADER:
{
char *header = va_arg(args, char*);
this->headers = curl_slist_append(this->headers, header);
- return TRUE;
+ break;
}
case FETCH_HTTP_VERSION_1_0:
{
curl_easy_setopt(this->curl, CURLOPT_HTTP_VERSION,
CURL_HTTP_VERSION_1_0);
- return TRUE;
+ break;
}
case FETCH_TIMEOUT:
{
curl_easy_setopt(this->curl, CURLOPT_CONNECTTIMEOUT,
va_arg(args, u_int));
- return TRUE;
+ break;
}
default:
- return FALSE;
+ supported = FALSE;
+ break;
}
+ va_end(args);
+ return supported;
}
METHOD(fetcher_t, destroy, void,
diff --git a/src/libstrongswan/plugins/curl/curl_plugin.c b/src/libstrongswan/plugins/curl/curl_plugin.c
index e00fcfc03..387da03aa 100644
--- a/src/libstrongswan/plugins/curl/curl_plugin.c
+++ b/src/libstrongswan/plugins/curl/curl_plugin.c
@@ -34,10 +34,8 @@ struct private_curl_plugin_t {
curl_plugin_t public;
};
-/**
- * Implementation of curl_plugin_t.curltroy
- */
-static void destroy(private_curl_plugin_t *this)
+METHOD(plugin_t, destroy, void,
+ private_curl_plugin_t *this)
{
lib->fetcher->remove_fetcher(lib->fetcher,
(fetcher_constructor_t)curl_fetcher_create);
@@ -51,9 +49,15 @@ static void destroy(private_curl_plugin_t *this)
plugin_t *curl_plugin_create()
{
CURLcode res;
- private_curl_plugin_t *this = malloc_thing(private_curl_plugin_t);
+ private_curl_plugin_t *this;
- this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
res = curl_global_init(CURL_GLOBAL_NOTHING);
if (res == CURLE_OK)
diff --git a/src/libstrongswan/plugins/des/Makefile.in b/src/libstrongswan/plugins/des/Makefile.in
index 0e8fa7315..e45988ca9 100644
--- a/src/libstrongswan/plugins/des/Makefile.in
+++ b/src/libstrongswan/plugins/des/Makefile.in
@@ -219,9 +219,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -260,6 +258,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/des/des_plugin.c b/src/libstrongswan/plugins/des/des_plugin.c
index 43b457ce2..d420d789e 100644
--- a/src/libstrongswan/plugins/des/des_plugin.c
+++ b/src/libstrongswan/plugins/des/des_plugin.c
@@ -18,6 +18,8 @@
#include <library.h>
#include "des_crypter.h"
+static const char *plugin_name = "des";
+
typedef struct private_des_plugin_t private_des_plugin_t;
/**
@@ -54,11 +56,11 @@ plugin_t *des_plugin_create()
},
);
- lib->crypto->add_crypter(lib->crypto, ENCR_3DES,
+ lib->crypto->add_crypter(lib->crypto, ENCR_3DES, plugin_name,
(crypter_constructor_t)des_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_DES,
+ lib->crypto->add_crypter(lib->crypto, ENCR_DES, plugin_name,
(crypter_constructor_t)des_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_DES_ECB,
+ lib->crypto->add_crypter(lib->crypto, ENCR_DES_ECB, plugin_name,
(crypter_constructor_t)des_crypter_create);
return &this->public.plugin;
diff --git a/src/libstrongswan/plugins/dnskey/Makefile.in b/src/libstrongswan/plugins/dnskey/Makefile.in
index 7f4529211..d1dce4679 100644
--- a/src/libstrongswan/plugins/dnskey/Makefile.in
+++ b/src/libstrongswan/plugins/dnskey/Makefile.in
@@ -222,9 +222,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -263,6 +261,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/dnskey/dnskey_plugin.c b/src/libstrongswan/plugins/dnskey/dnskey_plugin.c
index bc0ee30ae..d11b149df 100644
--- a/src/libstrongswan/plugins/dnskey/dnskey_plugin.c
+++ b/src/libstrongswan/plugins/dnskey/dnskey_plugin.c
@@ -31,10 +31,8 @@ struct private_dnskey_plugin_t {
dnskey_plugin_t public;
};
-/**
- * Implementation of dnskey_plugin_t.dnskeytroy
- */
-static void destroy(private_dnskey_plugin_t *this)
+METHOD(plugin_t, destroy, void,
+ private_dnskey_plugin_t *this)
{
lib->creds->remove_builder(lib->creds,
(builder_function_t)dnskey_public_key_load);
@@ -46,10 +44,15 @@ static void destroy(private_dnskey_plugin_t *this)
*/
plugin_t *dnskey_plugin_create()
{
- private_dnskey_plugin_t *this = malloc_thing(private_dnskey_plugin_t);
-
- this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-
+ private_dnskey_plugin_t *this;
+
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_ANY, FALSE,
(builder_function_t)dnskey_public_key_load);
lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_RSA, FALSE,
diff --git a/src/libstrongswan/plugins/fips_prf/Makefile.in b/src/libstrongswan/plugins/fips_prf/Makefile.in
index 7e2a1ccdf..ab1ed6d00 100644
--- a/src/libstrongswan/plugins/fips_prf/Makefile.in
+++ b/src/libstrongswan/plugins/fips_prf/Makefile.in
@@ -222,9 +222,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -263,6 +261,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/fips_prf/fips_prf.c b/src/libstrongswan/plugins/fips_prf/fips_prf.c
index ad03fa585..ee71f6efd 100644
--- a/src/libstrongswan/plugins/fips_prf/fips_prf.c
+++ b/src/libstrongswan/plugins/fips_prf/fips_prf.c
@@ -106,7 +106,8 @@ static void chunk_mod(size_t length, chunk_t chunk, u_int8_t buffer[])
* 0xcb, 0x0f, 0x6c, 0x55, 0xba, 0xbb, 0x13, 0x78,
* 0x8e, 0x20, 0xd7, 0x37, 0xa3, 0x27, 0x51, 0x16
*/
-static void get_bytes(private_fips_prf_t *this, chunk_t seed, u_int8_t w[])
+METHOD(prf_t, get_bytes, void,
+ private_fips_prf_t *this, chunk_t seed, u_int8_t w[])
{
int i;
u_int8_t xval[this->b];
@@ -139,34 +140,26 @@ static void get_bytes(private_fips_prf_t *this, chunk_t seed, u_int8_t w[])
/* 3.3 done already, mod q not used */
}
-/**
- * Implementation of prf_t.get_block_size.
- */
-static size_t get_block_size(private_fips_prf_t *this)
+METHOD(prf_t, get_block_size, size_t,
+ private_fips_prf_t *this)
{
return 2 * this->b;
}
-/**
- * Implementation of prf_t.allocate_bytes.
- */
-static void allocate_bytes(private_fips_prf_t *this, chunk_t seed, chunk_t *chunk)
+METHOD(prf_t, allocate_bytes, void,
+ private_fips_prf_t *this, chunk_t seed, chunk_t *chunk)
{
*chunk = chunk_alloc(get_block_size(this));
get_bytes(this, seed, chunk->ptr);
}
-/**
- * Implementation of prf_t.get_key_size.
- */
-static size_t get_key_size(private_fips_prf_t *this)
+METHOD(prf_t, get_key_size, size_t,
+ private_fips_prf_t *this)
{
return this->b;
}
-/**
- * Implementation of prf_t.set_key.
- */
-static void set_key(private_fips_prf_t *this, chunk_t key)
+METHOD(prf_t, set_key, void,
+ private_fips_prf_t *this, chunk_t key)
{
/* save key as "key mod 2^b" */
chunk_mod(this->b, key, this->key);
@@ -198,10 +191,8 @@ void g_sha1(private_fips_prf_t *this, chunk_t c, u_int8_t res[])
this->keyed_prf->get_bytes(this->keyed_prf, c, res);
}
-/**
- * Implementation of prf_t.destroy.
- */
-static void destroy(private_fips_prf_t *this)
+METHOD(prf_t, destroy, void,
+ private_fips_prf_t *this)
{
this->keyed_prf->destroy(this->keyed_prf);
free(this->key);
@@ -213,14 +204,20 @@ static void destroy(private_fips_prf_t *this)
*/
fips_prf_t *fips_prf_create(pseudo_random_function_t algo)
{
- private_fips_prf_t *this = malloc_thing(private_fips_prf_t);
-
- this->public.prf_interface.get_bytes = (void (*) (prf_t *,chunk_t,u_int8_t*))get_bytes;
- this->public.prf_interface.allocate_bytes = (void (*) (prf_t*,chunk_t,chunk_t*))allocate_bytes;
- this->public.prf_interface.get_block_size = (size_t (*) (prf_t*))get_block_size;
- this->public.prf_interface.get_key_size = (size_t (*) (prf_t*))get_key_size;
- this->public.prf_interface.set_key = (void (*) (prf_t *,chunk_t))set_key;
- this->public.prf_interface.destroy = (void (*) (prf_t *))destroy;
+ private_fips_prf_t *this;
+
+ INIT(this,
+ .public = {
+ .prf_interface = {
+ .get_bytes = _get_bytes,
+ .allocate_bytes = _allocate_bytes,
+ .get_block_size = _get_block_size,
+ .get_key_size = _get_key_size,
+ .set_key = _set_key,
+ .destroy = _destroy,
+ },
+ },
+ );
switch (algo)
{
diff --git a/src/libstrongswan/plugins/fips_prf/fips_prf_plugin.c b/src/libstrongswan/plugins/fips_prf/fips_prf_plugin.c
index f41265637..3cce6ad91 100644
--- a/src/libstrongswan/plugins/fips_prf/fips_prf_plugin.c
+++ b/src/libstrongswan/plugins/fips_prf/fips_prf_plugin.c
@@ -18,6 +18,8 @@
#include <library.h>
#include "fips_prf.h"
+static const char *plugin_name = "fips-prf";
+
typedef struct private_fips_prf_plugin_t private_fips_prf_plugin_t;
/**
@@ -31,10 +33,8 @@ struct private_fips_prf_plugin_t {
fips_prf_plugin_t public;
};
-/**
- * Implementation of fips_prf_plugin_t.destroy
- */
-static void destroy(private_fips_prf_plugin_t *this)
+METHOD(plugin_t, destroy, void,
+ private_fips_prf_plugin_t *this)
{
lib->crypto->remove_prf(lib->crypto,
(prf_constructor_t)fips_prf_create);
@@ -46,12 +46,24 @@ static void destroy(private_fips_prf_plugin_t *this)
*/
plugin_t *fips_prf_plugin_create()
{
- private_fips_prf_plugin_t *this = malloc_thing(private_fips_prf_plugin_t);
+ private_fips_prf_plugin_t *this;
+ prf_t *prf;
- this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
- lib->crypto->add_prf(lib->crypto, PRF_FIPS_SHA1_160,
- (prf_constructor_t)fips_prf_create);
+ prf = lib->crypto->create_prf(lib->crypto, PRF_KEYED_SHA1);
+ if (prf)
+ {
+ prf->destroy(prf);
+ lib->crypto->add_prf(lib->crypto, PRF_FIPS_SHA1_160, plugin_name,
+ (prf_constructor_t)fips_prf_create);
+ }
return &this->public.plugin;
}
diff --git a/src/libstrongswan/plugins/gcm/Makefile.in b/src/libstrongswan/plugins/gcm/Makefile.in
index a4de9ea77..9e0b49776 100644
--- a/src/libstrongswan/plugins/gcm/Makefile.in
+++ b/src/libstrongswan/plugins/gcm/Makefile.in
@@ -219,9 +219,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -260,6 +258,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/gcm/gcm_plugin.c b/src/libstrongswan/plugins/gcm/gcm_plugin.c
index 061001b30..a438fb073 100644
--- a/src/libstrongswan/plugins/gcm/gcm_plugin.c
+++ b/src/libstrongswan/plugins/gcm/gcm_plugin.c
@@ -19,6 +19,8 @@
#include "gcm_aead.h"
+static const char *plugin_name = "gcm";
+
typedef struct private_gcm_plugin_t private_gcm_plugin_t;
/**
@@ -47,17 +49,23 @@ METHOD(plugin_t, destroy, void,
plugin_t *gcm_plugin_create()
{
private_gcm_plugin_t *this;
+ crypter_t *crypter;
INIT(this,
.public.plugin.destroy = _destroy,
);
- lib->crypto->add_aead(lib->crypto, ENCR_AES_GCM_ICV8,
- (aead_constructor_t)gcm_aead_create);
- lib->crypto->add_aead(lib->crypto, ENCR_AES_GCM_ICV12,
- (aead_constructor_t)gcm_aead_create);
- lib->crypto->add_aead(lib->crypto, ENCR_AES_GCM_ICV16,
- (aead_constructor_t)gcm_aead_create);
+ crypter = lib->crypto->create_crypter(lib->crypto, ENCR_AES_CBC, 0);
+ if (crypter)
+ {
+ crypter->destroy(crypter);
+ lib->crypto->add_aead(lib->crypto, ENCR_AES_GCM_ICV8, plugin_name,
+ (aead_constructor_t)gcm_aead_create);
+ lib->crypto->add_aead(lib->crypto, ENCR_AES_GCM_ICV12, plugin_name,
+ (aead_constructor_t)gcm_aead_create);
+ lib->crypto->add_aead(lib->crypto, ENCR_AES_GCM_ICV16, plugin_name,
+ (aead_constructor_t)gcm_aead_create);
+ }
return &this->public.plugin;
}
diff --git a/src/libstrongswan/plugins/gcrypt/Makefile.in b/src/libstrongswan/plugins/gcrypt/Makefile.in
index 00c49c487..1bcada7dc 100644
--- a/src/libstrongswan/plugins/gcrypt/Makefile.in
+++ b/src/libstrongswan/plugins/gcrypt/Makefile.in
@@ -223,9 +223,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -264,6 +262,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/gcrypt/gcrypt_plugin.c b/src/libstrongswan/plugins/gcrypt/gcrypt_plugin.c
index 590add5c8..a53fed448 100644
--- a/src/libstrongswan/plugins/gcrypt/gcrypt_plugin.c
+++ b/src/libstrongswan/plugins/gcrypt/gcrypt_plugin.c
@@ -29,6 +29,8 @@
#include <errno.h>
#include <gcrypt.h>
+static const char *plugin_name = "gcrypt";
+
typedef struct private_gcrypt_plugin_t private_gcrypt_plugin_t;
/**
@@ -148,79 +150,79 @@ plugin_t *gcrypt_plugin_create()
);
/* hashers */
- lib->crypto->add_hasher(lib->crypto, HASH_SHA1,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA1, plugin_name,
(hasher_constructor_t)gcrypt_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_MD4,
+ lib->crypto->add_hasher(lib->crypto, HASH_MD4, plugin_name,
(hasher_constructor_t)gcrypt_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_MD5,
+ lib->crypto->add_hasher(lib->crypto, HASH_MD5, plugin_name,
(hasher_constructor_t)gcrypt_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_SHA224,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA224, plugin_name,
(hasher_constructor_t)gcrypt_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_SHA256,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA256, plugin_name,
(hasher_constructor_t)gcrypt_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_SHA384,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA384, plugin_name,
(hasher_constructor_t)gcrypt_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_SHA512,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA512, plugin_name,
(hasher_constructor_t)gcrypt_hasher_create);
/* crypters */
- lib->crypto->add_crypter(lib->crypto, ENCR_3DES,
+ lib->crypto->add_crypter(lib->crypto, ENCR_3DES, plugin_name,
(crypter_constructor_t)gcrypt_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_CAST,
+ lib->crypto->add_crypter(lib->crypto, ENCR_CAST, plugin_name,
(crypter_constructor_t)gcrypt_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_BLOWFISH,
+ lib->crypto->add_crypter(lib->crypto, ENCR_BLOWFISH, plugin_name,
(crypter_constructor_t)gcrypt_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_DES,
+ lib->crypto->add_crypter(lib->crypto, ENCR_DES, plugin_name,
(crypter_constructor_t)gcrypt_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_DES_ECB,
+ lib->crypto->add_crypter(lib->crypto, ENCR_DES_ECB, plugin_name,
(crypter_constructor_t)gcrypt_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_AES_CBC,
+ lib->crypto->add_crypter(lib->crypto, ENCR_AES_CBC, plugin_name,
(crypter_constructor_t)gcrypt_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_AES_CTR,
+ lib->crypto->add_crypter(lib->crypto, ENCR_AES_CTR, plugin_name,
(crypter_constructor_t)gcrypt_crypter_create);
#ifdef HAVE_GCRY_CIPHER_CAMELLIA
- lib->crypto->add_crypter(lib->crypto, ENCR_CAMELLIA_CBC,
+ lib->crypto->add_crypter(lib->crypto, ENCR_CAMELLIA_CBC, plugin_name,
(crypter_constructor_t)gcrypt_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_CAMELLIA_CTR,
+ lib->crypto->add_crypter(lib->crypto, ENCR_CAMELLIA_CTR, plugin_name,
(crypter_constructor_t)gcrypt_crypter_create);
#endif /* HAVE_GCRY_CIPHER_CAMELLIA */
- lib->crypto->add_crypter(lib->crypto, ENCR_SERPENT_CBC,
+ lib->crypto->add_crypter(lib->crypto, ENCR_SERPENT_CBC, plugin_name,
(crypter_constructor_t)gcrypt_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_TWOFISH_CBC,
+ lib->crypto->add_crypter(lib->crypto, ENCR_TWOFISH_CBC, plugin_name,
(crypter_constructor_t)gcrypt_crypter_create);
/* random numbers */
- lib->crypto->add_rng(lib->crypto, RNG_WEAK,
+ lib->crypto->add_rng(lib->crypto, RNG_WEAK, plugin_name,
(rng_constructor_t)gcrypt_rng_create);
- lib->crypto->add_rng(lib->crypto, RNG_STRONG,
+ lib->crypto->add_rng(lib->crypto, RNG_STRONG, plugin_name,
(rng_constructor_t)gcrypt_rng_create);
- lib->crypto->add_rng(lib->crypto, RNG_TRUE,
+ lib->crypto->add_rng(lib->crypto, RNG_TRUE, plugin_name,
(rng_constructor_t)gcrypt_rng_create);
/* diffie hellman groups, using modp */
- lib->crypto->add_dh(lib->crypto, MODP_2048_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_2048_BIT, plugin_name,
(dh_constructor_t)gcrypt_dh_create);
- lib->crypto->add_dh(lib->crypto, MODP_2048_224,
+ lib->crypto->add_dh(lib->crypto, MODP_2048_224, plugin_name,
(dh_constructor_t)gcrypt_dh_create);
- lib->crypto->add_dh(lib->crypto, MODP_2048_256,
+ lib->crypto->add_dh(lib->crypto, MODP_2048_256, plugin_name,
(dh_constructor_t)gcrypt_dh_create);
- lib->crypto->add_dh(lib->crypto, MODP_1536_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_1536_BIT, plugin_name,
(dh_constructor_t)gcrypt_dh_create);
- lib->crypto->add_dh(lib->crypto, MODP_3072_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_3072_BIT, plugin_name,
(dh_constructor_t)gcrypt_dh_create);
- lib->crypto->add_dh(lib->crypto, MODP_4096_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_4096_BIT, plugin_name,
(dh_constructor_t)gcrypt_dh_create);
- lib->crypto->add_dh(lib->crypto, MODP_6144_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_6144_BIT, plugin_name,
(dh_constructor_t)gcrypt_dh_create);
- lib->crypto->add_dh(lib->crypto, MODP_8192_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_8192_BIT, plugin_name,
(dh_constructor_t)gcrypt_dh_create);
- lib->crypto->add_dh(lib->crypto, MODP_1024_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_1024_BIT, plugin_name,
(dh_constructor_t)gcrypt_dh_create);
- lib->crypto->add_dh(lib->crypto, MODP_1024_160,
+ lib->crypto->add_dh(lib->crypto, MODP_1024_160, plugin_name,
(dh_constructor_t)gcrypt_dh_create);
- lib->crypto->add_dh(lib->crypto, MODP_768_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_768_BIT, plugin_name,
(dh_constructor_t)gcrypt_dh_create);
- lib->crypto->add_dh(lib->crypto, MODP_CUSTOM,
+ lib->crypto->add_dh(lib->crypto, MODP_CUSTOM, plugin_name,
(dh_constructor_t)gcrypt_dh_create_custom);
/* RSA */
diff --git a/src/libstrongswan/plugins/gmp/Makefile.in b/src/libstrongswan/plugins/gmp/Makefile.in
index b4ec1ed8d..f73bfb406 100644
--- a/src/libstrongswan/plugins/gmp/Makefile.in
+++ b/src/libstrongswan/plugins/gmp/Makefile.in
@@ -220,9 +220,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -261,6 +259,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/gmp/gmp_plugin.c b/src/libstrongswan/plugins/gmp/gmp_plugin.c
index 9b4fad3da..e9bfbcc28 100644
--- a/src/libstrongswan/plugins/gmp/gmp_plugin.c
+++ b/src/libstrongswan/plugins/gmp/gmp_plugin.c
@@ -20,6 +20,8 @@
#include "gmp_rsa_private_key.h"
#include "gmp_rsa_public_key.h"
+static const char *plugin_name = "gmp";
+
typedef struct private_gmp_plugin_t private_gmp_plugin_t;
/**
@@ -64,30 +66,30 @@ plugin_t *gmp_plugin_create()
},
);
- lib->crypto->add_dh(lib->crypto, MODP_2048_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_2048_BIT, plugin_name,
(dh_constructor_t)gmp_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_2048_224,
+ lib->crypto->add_dh(lib->crypto, MODP_2048_224, plugin_name,
(dh_constructor_t)gmp_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_2048_256,
+ lib->crypto->add_dh(lib->crypto, MODP_2048_256, plugin_name,
(dh_constructor_t)gmp_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_1536_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_1536_BIT, plugin_name,
(dh_constructor_t)gmp_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_3072_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_3072_BIT, plugin_name,
(dh_constructor_t)gmp_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_4096_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_4096_BIT, plugin_name,
(dh_constructor_t)gmp_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_6144_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_6144_BIT, plugin_name,
(dh_constructor_t)gmp_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_8192_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_8192_BIT, plugin_name,
(dh_constructor_t)gmp_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_1024_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_1024_BIT, plugin_name,
(dh_constructor_t)gmp_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_1024_160,
+ lib->crypto->add_dh(lib->crypto, MODP_1024_160, plugin_name,
(dh_constructor_t)gmp_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_768_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_768_BIT, plugin_name,
(dh_constructor_t)gmp_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_CUSTOM,
+ lib->crypto->add_dh(lib->crypto, MODP_CUSTOM, plugin_name,
(dh_constructor_t)gmp_diffie_hellman_create_custom);
lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_RSA, FALSE,
diff --git a/src/libstrongswan/plugins/hmac/Makefile.in b/src/libstrongswan/plugins/hmac/Makefile.in
index 42a7d3747..72cc23b72 100644
--- a/src/libstrongswan/plugins/hmac/Makefile.in
+++ b/src/libstrongswan/plugins/hmac/Makefile.in
@@ -220,9 +220,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -261,6 +259,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/hmac/hmac_plugin.c b/src/libstrongswan/plugins/hmac/hmac_plugin.c
index 73df4dc6c..76d6157ae 100644
--- a/src/libstrongswan/plugins/hmac/hmac_plugin.c
+++ b/src/libstrongswan/plugins/hmac/hmac_plugin.c
@@ -19,6 +19,8 @@
#include "hmac_signer.h"
#include "hmac_prf.h"
+static const char *plugin_name = "hmac";
+
typedef struct private_hmac_plugin_t private_hmac_plugin_t;
/**
@@ -48,6 +50,7 @@ METHOD(plugin_t, destroy, void,
plugin_t *hmac_plugin_create()
{
private_hmac_plugin_t *this;
+ hasher_t *hasher;
INIT(this,
.public = {
@@ -57,37 +60,62 @@ plugin_t *hmac_plugin_create()
},
);
- lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_256,
- (prf_constructor_t)hmac_prf_create);
- lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA1,
- (prf_constructor_t)hmac_prf_create);
- lib->crypto->add_prf(lib->crypto, PRF_HMAC_MD5,
- (prf_constructor_t)hmac_prf_create);
- lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_384,
- (prf_constructor_t)hmac_prf_create);
- lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_512,
- (prf_constructor_t)hmac_prf_create);
+ hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
+ if (hasher)
+ {
+ hasher->destroy(hasher);
+ lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA1, plugin_name,
+ (prf_constructor_t)hmac_prf_create);
+ lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_96, plugin_name,
+ (signer_constructor_t)hmac_signer_create);
+ lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_128, plugin_name,
+ (signer_constructor_t)hmac_signer_create);
+ lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_160, plugin_name,
+ (signer_constructor_t)hmac_signer_create);
+ }
+ hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA256);
+ if (hasher)
+ {
+ hasher->destroy(hasher);
+ lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_256, plugin_name,
+ (prf_constructor_t)hmac_prf_create);
+ lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_256_128, plugin_name,
+ (signer_constructor_t)hmac_signer_create);
+ lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_256_256, plugin_name,
+ (signer_constructor_t)hmac_signer_create);
- lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_96,
- (signer_constructor_t)hmac_signer_create);
- lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_128,
- (signer_constructor_t)hmac_signer_create);
- lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA1_160,
- (signer_constructor_t)hmac_signer_create);
- lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_256_128,
- (signer_constructor_t)hmac_signer_create);
- lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_256_256,
- (signer_constructor_t)hmac_signer_create);
- lib->crypto->add_signer(lib->crypto, AUTH_HMAC_MD5_96,
- (signer_constructor_t)hmac_signer_create);
- lib->crypto->add_signer(lib->crypto, AUTH_HMAC_MD5_128,
- (signer_constructor_t)hmac_signer_create);
- lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_384_192,
- (signer_constructor_t)hmac_signer_create);
- lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_384_384,
- (signer_constructor_t)hmac_signer_create);
- lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_512_256,
- (signer_constructor_t)hmac_signer_create);
+ }
+ hasher = lib->crypto->create_hasher(lib->crypto, HASH_MD5);
+ if (hasher)
+ {
+ hasher->destroy(hasher);
+ lib->crypto->add_prf(lib->crypto, PRF_HMAC_MD5, plugin_name,
+ (prf_constructor_t)hmac_prf_create);
+ lib->crypto->add_signer(lib->crypto, AUTH_HMAC_MD5_96, plugin_name,
+ (signer_constructor_t)hmac_signer_create);
+ lib->crypto->add_signer(lib->crypto, AUTH_HMAC_MD5_128, plugin_name,
+ (signer_constructor_t)hmac_signer_create);
+ }
+ hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA384);
+ if (hasher)
+ {
+ hasher->destroy(hasher);
+ lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_384, plugin_name,
+ (prf_constructor_t)hmac_prf_create);
+ lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_384_192, plugin_name,
+ (signer_constructor_t)hmac_signer_create);
+ lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_384_384, plugin_name,
+ (signer_constructor_t)hmac_signer_create);
+ }
+ hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA512);
+ if (hasher)
+ {
+ hasher->destroy(hasher);
+ lib->crypto->add_prf(lib->crypto, PRF_HMAC_SHA2_512, plugin_name,
+ (prf_constructor_t)hmac_prf_create);
+ lib->crypto->add_signer(lib->crypto, AUTH_HMAC_SHA2_512_256, plugin_name,
+ (signer_constructor_t)hmac_signer_create);
+ }
return &this->public.plugin;
}
diff --git a/src/libstrongswan/plugins/ldap/Makefile.in b/src/libstrongswan/plugins/ldap/Makefile.in
index 65a135e76..7235784e2 100644
--- a/src/libstrongswan/plugins/ldap/Makefile.in
+++ b/src/libstrongswan/plugins/ldap/Makefile.in
@@ -219,9 +219,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -260,6 +258,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/ldap/ldap_fetcher.c b/src/libstrongswan/plugins/ldap/ldap_fetcher.c
index 59e655cd5..e6c592217 100644
--- a/src/libstrongswan/plugins/ldap/ldap_fetcher.c
+++ b/src/libstrongswan/plugins/ldap/ldap_fetcher.c
@@ -100,8 +100,8 @@ static bool parse(LDAP *ldap, LDAPMessage *result, chunk_t *response)
}
-static status_t fetch(private_ldap_fetcher_t *this, char *url,
- chunk_t *result, va_list args)
+METHOD(fetcher_t, fetch, status_t,
+ private_ldap_fetcher_t *this, char *url, chunk_t *result)
{
LDAP *ldap;
LDAPURLDesc *lurl;
@@ -166,10 +166,8 @@ static status_t fetch(private_ldap_fetcher_t *this, char *url,
}
-/**
- * Implementation of fetcher_t.set_option.
- */
-static bool set_option(private_ldap_fetcher_t *this, fetcher_option_t option, ...)
+METHOD(fetcher_t, set_option, bool,
+ private_ldap_fetcher_t *this, fetcher_option_t option, ...)
{
va_list args;
@@ -186,10 +184,8 @@ static bool set_option(private_ldap_fetcher_t *this, fetcher_option_t option, ..
}
}
-/**
- * Implements ldap_fetcher_t.destroy
- */
-static void destroy(private_ldap_fetcher_t *this)
+METHOD(fetcher_t, destroy, void,
+ private_ldap_fetcher_t *this)
{
free(this);
}
@@ -199,13 +195,18 @@ static void destroy(private_ldap_fetcher_t *this)
*/
ldap_fetcher_t *ldap_fetcher_create()
{
- private_ldap_fetcher_t *this = malloc_thing(private_ldap_fetcher_t);
-
- this->public.interface.fetch = (status_t(*)(fetcher_t*,char*,chunk_t*))fetch;
- this->public.interface.set_option = (bool(*)(fetcher_t*, fetcher_option_t option, ...))set_option;
- this->public.interface.destroy = (void (*)(fetcher_t*))destroy;
-
- this->timeout = DEFAULT_TIMEOUT;
+ private_ldap_fetcher_t *this;
+
+ INIT(this,
+ .public = {
+ .interface = {
+ .fetch = _fetch,
+ .set_option = _set_option,
+ .destroy = _destroy,
+ },
+ },
+ .timeout = DEFAULT_TIMEOUT,
+ );
return &this->public;
}
diff --git a/src/libstrongswan/plugins/ldap/ldap_plugin.c b/src/libstrongswan/plugins/ldap/ldap_plugin.c
index 372ac9f93..3682ddd1f 100644
--- a/src/libstrongswan/plugins/ldap/ldap_plugin.c
+++ b/src/libstrongswan/plugins/ldap/ldap_plugin.c
@@ -31,10 +31,8 @@ struct private_ldap_plugin_t {
ldap_plugin_t public;
};
-/**
- * Implementation of ldap_plugin_t.destroy
- */
-static void destroy(private_ldap_plugin_t *this)
+METHOD(plugin_t, destroy, void,
+ private_ldap_plugin_t *this)
{
lib->fetcher->remove_fetcher(lib->fetcher,
(fetcher_constructor_t)ldap_fetcher_create);
@@ -46,9 +44,15 @@ static void destroy(private_ldap_plugin_t *this)
*/
plugin_t *ldap_plugin_create()
{
- private_ldap_plugin_t *this = malloc_thing(private_ldap_plugin_t);
+ private_ldap_plugin_t *this;
- this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
lib->fetcher->add_fetcher(lib->fetcher,
(fetcher_constructor_t)ldap_fetcher_create, "ldap://");
diff --git a/src/libstrongswan/plugins/md4/Makefile.in b/src/libstrongswan/plugins/md4/Makefile.in
index a78dad97c..ea1a7a69a 100644
--- a/src/libstrongswan/plugins/md4/Makefile.in
+++ b/src/libstrongswan/plugins/md4/Makefile.in
@@ -219,9 +219,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -260,6 +258,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/md4/md4_plugin.c b/src/libstrongswan/plugins/md4/md4_plugin.c
index 38ae0d4bc..cea1a61f3 100644
--- a/src/libstrongswan/plugins/md4/md4_plugin.c
+++ b/src/libstrongswan/plugins/md4/md4_plugin.c
@@ -18,6 +18,8 @@
#include <library.h>
#include "md4_hasher.h"
+static const char *plugin_name = "md4";
+
typedef struct private_md4_plugin_t private_md4_plugin_t;
/**
@@ -31,10 +33,8 @@ struct private_md4_plugin_t {
md4_plugin_t public;
};
-/**
- * Implementation of md4_plugin_t.destroy
- */
-static void destroy(private_md4_plugin_t *this)
+METHOD(plugin_t, destroy, void,
+ private_md4_plugin_t *this)
{
lib->crypto->remove_hasher(lib->crypto,
(hasher_constructor_t)md4_hasher_create);
@@ -46,11 +46,17 @@ static void destroy(private_md4_plugin_t *this)
*/
plugin_t *md4_plugin_create()
{
- private_md4_plugin_t *this = malloc_thing(private_md4_plugin_t);
+ private_md4_plugin_t *this;
- this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
- lib->crypto->add_hasher(lib->crypto, HASH_MD4,
+ lib->crypto->add_hasher(lib->crypto, HASH_MD4, plugin_name,
(hasher_constructor_t)md4_hasher_create);
return &this->public.plugin;
diff --git a/src/libstrongswan/plugins/md5/Makefile.in b/src/libstrongswan/plugins/md5/Makefile.in
index 6de400e8e..05f101564 100644
--- a/src/libstrongswan/plugins/md5/Makefile.in
+++ b/src/libstrongswan/plugins/md5/Makefile.in
@@ -219,9 +219,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -260,6 +258,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/md5/md5_plugin.c b/src/libstrongswan/plugins/md5/md5_plugin.c
index cfbf6acea..d11173817 100644
--- a/src/libstrongswan/plugins/md5/md5_plugin.c
+++ b/src/libstrongswan/plugins/md5/md5_plugin.c
@@ -18,6 +18,8 @@
#include <library.h>
#include "md5_hasher.h"
+static const char *plugin_name = "md5";
+
typedef struct private_md5_plugin_t private_md5_plugin_t;
/**
@@ -31,10 +33,8 @@ struct private_md5_plugin_t {
md5_plugin_t public;
};
-/**
- * Implementation of md5_plugin_t.destroy
- */
-static void destroy(private_md5_plugin_t *this)
+METHOD(plugin_t, destroy, void,
+ private_md5_plugin_t *this)
{
lib->crypto->remove_hasher(lib->crypto,
(hasher_constructor_t)md5_hasher_create);
@@ -46,11 +46,17 @@ static void destroy(private_md5_plugin_t *this)
*/
plugin_t *md5_plugin_create()
{
- private_md5_plugin_t *this = malloc_thing(private_md5_plugin_t);
+ private_md5_plugin_t *this;
- this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
- lib->crypto->add_hasher(lib->crypto, HASH_MD5,
+ lib->crypto->add_hasher(lib->crypto, HASH_MD5, plugin_name,
(hasher_constructor_t)md5_hasher_create);
return &this->public.plugin;
diff --git a/src/libstrongswan/plugins/mysql/Makefile.in b/src/libstrongswan/plugins/mysql/Makefile.in
index 7d4d42c14..4880415b3 100644
--- a/src/libstrongswan/plugins/mysql/Makefile.in
+++ b/src/libstrongswan/plugins/mysql/Makefile.in
@@ -221,9 +221,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -262,6 +260,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/mysql/mysql_database.c b/src/libstrongswan/plugins/mysql/mysql_database.c
index 8005b9149..5fbfa0f28 100644
--- a/src/libstrongswan/plugins/mysql/mysql_database.c
+++ b/src/libstrongswan/plugins/mysql/mysql_database.c
@@ -474,10 +474,8 @@ static bool mysql_enumerator_enumerate(mysql_enumerator_t *this, ...)
return TRUE;
}
-/**
- * Implementation of database_t.query.
- */
-static enumerator_t* query(private_mysql_database_t *this, char *sql, ...)
+METHOD(database_t, query, enumerator_t*,
+ private_mysql_database_t *this, char *sql, ...)
{
MYSQL_STMT *stmt;
va_list args;
@@ -563,10 +561,8 @@ static enumerator_t* query(private_mysql_database_t *this, char *sql, ...)
return (enumerator_t*)enumerator;
}
-/**
- * Implementation of database_t.execute.
- */
-static int execute(private_mysql_database_t *this, int *rowid, char *sql, ...)
+METHOD(database_t, execute, int,
+ private_mysql_database_t *this, int *rowid, char *sql, ...)
{
MYSQL_STMT *stmt;
va_list args;
@@ -594,18 +590,14 @@ static int execute(private_mysql_database_t *this, int *rowid, char *sql, ...)
return affected;
}
-/**
- * Implementation of database_t.get_driver
- */
-static db_driver_t get_driver(private_mysql_database_t *this)
+METHOD(database_t, get_driver,db_driver_t,
+ private_mysql_database_t *this)
{
return DB_MYSQL;
}
-/**
- * Implementation of database_t.destroy
- */
-static void destroy(private_mysql_database_t *this)
+METHOD(database_t, destroy, void,
+ private_mysql_database_t *this)
{
this->pool->destroy_function(this->pool, (void*)conn_destroy);
this->mutex->destroy(this->mutex);
@@ -677,12 +669,16 @@ mysql_database_t *mysql_database_create(char *uri)
return NULL;
}
- this = malloc_thing(private_mysql_database_t);
-
- this->public.db.query = (enumerator_t* (*)(database_t *this, char *sql, ...))query;
- this->public.db.execute = (int (*)(database_t *this, int *rowid, char *sql, ...))execute;
- this->public.db.get_driver = (db_driver_t(*)(database_t*))get_driver;
- this->public.db.destroy = (void(*)(database_t*))destroy;
+ INIT(this,
+ .public = {
+ .db = {
+ .query = _query,
+ .execute = _execute,
+ .get_driver = _get_driver,
+ .destroy = _destroy,
+ },
+ },
+ );
if (!parse_uri(this, uri))
{
diff --git a/src/libstrongswan/plugins/mysql/mysql_plugin.c b/src/libstrongswan/plugins/mysql/mysql_plugin.c
index a13aa8091..65d8681cb 100644
--- a/src/libstrongswan/plugins/mysql/mysql_plugin.c
+++ b/src/libstrongswan/plugins/mysql/mysql_plugin.c
@@ -32,10 +32,8 @@ struct private_mysql_plugin_t {
mysql_plugin_t public;
};
-/**
- * Implementation of plugin_t.destroy
- */
-static void destroy(private_mysql_plugin_t *this)
+METHOD(plugin_t, destroy, void,
+ private_mysql_plugin_t *this)
{
lib->db->remove_database(lib->db,
(database_constructor_t)mysql_database_create);
@@ -56,8 +54,13 @@ plugin_t *mysql_plugin_create()
return NULL;
}
- this = malloc_thing(private_mysql_plugin_t);
- this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
lib->db->add_database(lib->db,
(database_constructor_t)mysql_database_create);
diff --git a/src/libstrongswan/plugins/openssl/Makefile.in b/src/libstrongswan/plugins/openssl/Makefile.in
index a32418b16..b43be29f1 100644
--- a/src/libstrongswan/plugins/openssl/Makefile.in
+++ b/src/libstrongswan/plugins/openssl/Makefile.in
@@ -226,9 +226,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -267,6 +265,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/openssl/openssl_crl.c b/src/libstrongswan/plugins/openssl/openssl_crl.c
index b9d97a901..58401faa5 100644
--- a/src/libstrongswan/plugins/openssl/openssl_crl.c
+++ b/src/libstrongswan/plugins/openssl/openssl_crl.c
@@ -382,6 +382,8 @@ static private_openssl_crl_t *create_empty()
},
.get_serial = _get_serial,
.get_authKeyIdentifier = _get_authKeyIdentifier,
+ .is_delta_crl = (void*)return_false,
+ .create_delta_crl_uri_enumerator = (void*)enumerator_create_empty,
.create_enumerator = _create_enumerator,
},
},
@@ -458,7 +460,14 @@ static bool parse_extensions(private_openssl_crl_t *this)
ok = parse_crlNumber_ext(this, ext);
break;
default:
- ok = TRUE;
+ ok = X509_EXTENSION_get_critical(ext) == 0 ||
+ !lib->settings->get_bool(lib->settings,
+ "libstrongswan.x509.enforce_critical", TRUE);
+ if (!ok)
+ {
+ DBG1(DBG_LIB, "found unsupported critical X.509 "
+ "CRL extension");
+ }
break;
}
if (!ok)
diff --git a/src/libstrongswan/plugins/openssl/openssl_plugin.c b/src/libstrongswan/plugins/openssl/openssl_plugin.c
index 0ab4eda9c..0050572ee 100644
--- a/src/libstrongswan/plugins/openssl/openssl_plugin.c
+++ b/src/libstrongswan/plugins/openssl/openssl_plugin.c
@@ -41,6 +41,8 @@
#include "openssl_x509.h"
#include "openssl_crl.h"
+static const char *plugin_name = "openssl";
+
typedef struct private_openssl_plugin_t private_openssl_plugin_t;
/**
@@ -272,85 +274,85 @@ plugin_t *openssl_plugin_create()
}
/* crypter */
- lib->crypto->add_crypter(lib->crypto, ENCR_AES_CBC,
+ lib->crypto->add_crypter(lib->crypto, ENCR_AES_CBC, plugin_name,
(crypter_constructor_t)openssl_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_CAMELLIA_CBC,
+ lib->crypto->add_crypter(lib->crypto, ENCR_CAMELLIA_CBC, plugin_name,
(crypter_constructor_t)openssl_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_3DES,
+ lib->crypto->add_crypter(lib->crypto, ENCR_3DES, plugin_name,
(crypter_constructor_t)openssl_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_RC5,
+ lib->crypto->add_crypter(lib->crypto, ENCR_RC5, plugin_name,
(crypter_constructor_t)openssl_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_IDEA,
+ lib->crypto->add_crypter(lib->crypto, ENCR_IDEA, plugin_name,
(crypter_constructor_t)openssl_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_CAST,
+ lib->crypto->add_crypter(lib->crypto, ENCR_CAST, plugin_name,
(crypter_constructor_t)openssl_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_BLOWFISH,
+ lib->crypto->add_crypter(lib->crypto, ENCR_BLOWFISH, plugin_name,
(crypter_constructor_t)openssl_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_DES,
+ lib->crypto->add_crypter(lib->crypto, ENCR_DES, plugin_name,
(crypter_constructor_t)openssl_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_DES_ECB,
+ lib->crypto->add_crypter(lib->crypto, ENCR_DES_ECB, plugin_name,
(crypter_constructor_t)openssl_crypter_create);
- lib->crypto->add_crypter(lib->crypto, ENCR_NULL,
+ lib->crypto->add_crypter(lib->crypto, ENCR_NULL, plugin_name,
(crypter_constructor_t)openssl_crypter_create);
/* hasher */
- lib->crypto->add_hasher(lib->crypto, HASH_SHA1,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA1, plugin_name,
(hasher_constructor_t)openssl_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_MD2,
+ lib->crypto->add_hasher(lib->crypto, HASH_MD2, plugin_name,
(hasher_constructor_t)openssl_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_MD4,
+ lib->crypto->add_hasher(lib->crypto, HASH_MD4, plugin_name,
(hasher_constructor_t)openssl_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_MD5,
+ lib->crypto->add_hasher(lib->crypto, HASH_MD5, plugin_name,
(hasher_constructor_t)openssl_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_SHA224,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA224, plugin_name,
(hasher_constructor_t)openssl_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_SHA256,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA256, plugin_name,
(hasher_constructor_t)openssl_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_SHA384,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA384, plugin_name,
(hasher_constructor_t)openssl_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_SHA512,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA512, plugin_name,
(hasher_constructor_t)openssl_hasher_create);
/* prf */
- lib->crypto->add_prf(lib->crypto, PRF_KEYED_SHA1,
+ lib->crypto->add_prf(lib->crypto, PRF_KEYED_SHA1, plugin_name,
(prf_constructor_t)openssl_sha1_prf_create);
/* (ec) diffie hellman */
- lib->crypto->add_dh(lib->crypto, MODP_2048_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_2048_BIT, plugin_name,
(dh_constructor_t)openssl_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_2048_224,
+ lib->crypto->add_dh(lib->crypto, MODP_2048_224, plugin_name,
(dh_constructor_t)openssl_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_2048_256,
+ lib->crypto->add_dh(lib->crypto, MODP_2048_256, plugin_name,
(dh_constructor_t)openssl_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_1536_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_1536_BIT, plugin_name,
(dh_constructor_t)openssl_diffie_hellman_create);
#ifndef OPENSSL_NO_EC
- lib->crypto->add_dh(lib->crypto, ECP_256_BIT,
+ lib->crypto->add_dh(lib->crypto, ECP_256_BIT, plugin_name,
(dh_constructor_t)openssl_ec_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, ECP_384_BIT,
+ lib->crypto->add_dh(lib->crypto, ECP_384_BIT, plugin_name,
(dh_constructor_t)openssl_ec_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, ECP_521_BIT,
+ lib->crypto->add_dh(lib->crypto, ECP_521_BIT, plugin_name,
(dh_constructor_t)openssl_ec_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, ECP_224_BIT,
+ lib->crypto->add_dh(lib->crypto, ECP_224_BIT, plugin_name,
(dh_constructor_t)openssl_ec_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, ECP_192_BIT,
+ lib->crypto->add_dh(lib->crypto, ECP_192_BIT, plugin_name,
(dh_constructor_t)openssl_ec_diffie_hellman_create);
#endif /* OPENSSL_NO_EC */
- lib->crypto->add_dh(lib->crypto, MODP_3072_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_3072_BIT, plugin_name,
(dh_constructor_t)openssl_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_4096_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_4096_BIT, plugin_name,
(dh_constructor_t)openssl_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_6144_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_6144_BIT, plugin_name,
(dh_constructor_t)openssl_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_8192_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_8192_BIT, plugin_name,
(dh_constructor_t)openssl_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_1024_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_1024_BIT, plugin_name,
(dh_constructor_t)openssl_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_1024_160,
+ lib->crypto->add_dh(lib->crypto, MODP_1024_160, plugin_name,
(dh_constructor_t)openssl_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_768_BIT,
+ lib->crypto->add_dh(lib->crypto, MODP_768_BIT, plugin_name,
(dh_constructor_t)openssl_diffie_hellman_create);
- lib->crypto->add_dh(lib->crypto, MODP_CUSTOM,
+ lib->crypto->add_dh(lib->crypto, MODP_CUSTOM, plugin_name,
(dh_constructor_t)openssl_diffie_hellman_create);
/* rsa */
diff --git a/src/libstrongswan/plugins/openssl/openssl_x509.c b/src/libstrongswan/plugins/openssl/openssl_x509.c
index aa39bc93d..f7495b2ae 100644
--- a/src/libstrongswan/plugins/openssl/openssl_x509.c
+++ b/src/libstrongswan/plugins/openssl/openssl_x509.c
@@ -84,7 +84,7 @@ struct private_openssl_x509_t {
/**
* Pathlen constraint
*/
- int pathlen;
+ u_char pathlen;
/**
* certificate subject
@@ -137,7 +137,7 @@ struct private_openssl_x509_t {
linked_list_t *issuerAltNames;
/**
- * List of CRL URIs
+ * List of CRL URIs, as x509_cdp_t
*/
linked_list_t *crl_uris;
@@ -153,6 +153,16 @@ struct private_openssl_x509_t {
};
/**
+ * Destroy a CRL URI struct
+ */
+static void crl_uri_destroy(x509_cdp_t *this)
+{
+ free(this->uri);
+ DESTROY_IF(this->issuer);
+ free(this);
+}
+
+/**
* Convert a GeneralName to an identification_t.
*/
static identification_t *general_name2id(GENERAL_NAME *name)
@@ -240,10 +250,16 @@ METHOD(x509_t, get_authKeyIdentifier, chunk_t,
return chunk_empty;
}
-METHOD(x509_t, get_pathLenConstraint, int,
- private_openssl_x509_t *this)
+METHOD(x509_t, get_constraint, u_int,
+ private_openssl_x509_t *this, x509_constraint_t type)
{
- return this->pathlen;
+ switch (type)
+ {
+ case X509_PATH_LEN:
+ return this->pathlen;
+ default:
+ return X509_NO_CONSTRAINT;
+ }
}
METHOD(x509_t, create_subjectAltName_enumerator, enumerator_t*,
@@ -264,13 +280,6 @@ METHOD(x509_t, create_ocsp_uri_enumerator, enumerator_t*,
return this->ocsp_uris->create_enumerator(this->ocsp_uris);
}
-METHOD(x509_t, create_ipAddrBlock_enumerator, enumerator_t*,
- private_openssl_x509_t *this)
-{
- /* TODO */
- return enumerator_create_empty();
-}
-
METHOD(certificate_t, get_type, certificate_type_t,
private_openssl_x509_t *this)
{
@@ -483,7 +492,7 @@ METHOD(certificate_t, destroy, void,
offsetof(identification_t, destroy));
this->issuerAltNames->destroy_offset(this->issuerAltNames,
offsetof(identification_t, destroy));
- this->crl_uris->destroy_function(this->crl_uris, free);
+ this->crl_uris->destroy_function(this->crl_uris, (void*)crl_uri_destroy);
this->ocsp_uris->destroy_function(this->ocsp_uris, free);
free(this);
}
@@ -517,18 +526,21 @@ static private_openssl_x509_t *create_empty()
.get_serial = _get_serial,
.get_subjectKeyIdentifier = _get_subjectKeyIdentifier,
.get_authKeyIdentifier = _get_authKeyIdentifier,
- .get_pathLenConstraint = _get_pathLenConstraint,
+ .get_constraint = _get_constraint,
.create_subjectAltName_enumerator = _create_subjectAltName_enumerator,
.create_crl_uri_enumerator = _create_crl_uri_enumerator,
.create_ocsp_uri_enumerator = _create_ocsp_uri_enumerator,
- .create_ipAddrBlock_enumerator = _create_ipAddrBlock_enumerator,
+ .create_ipAddrBlock_enumerator = (void*)enumerator_create_empty,
+ .create_name_constraint_enumerator = (void*)enumerator_create_empty,
+ .create_cert_policy_enumerator = (void*)enumerator_create_empty,
+ .create_policy_mapping_enumerator = (void*)enumerator_create_empty,
},
},
.subjectAltNames = linked_list_create(),
.issuerAltNames = linked_list_create(),
.crl_uris = linked_list_create(),
.ocsp_uris = linked_list_create(),
- .pathlen = X509_NO_PATH_LEN_CONSTRAINT,
+ .pathlen = X509_NO_CONSTRAINT,
.ref = 1,
);
@@ -574,6 +586,7 @@ static bool parse_basicConstraints_ext(private_openssl_x509_t *this,
X509_EXTENSION *ext)
{
BASIC_CONSTRAINTS *constraints;
+ long pathlen;
constraints = (BASIC_CONSTRAINTS*)X509V3_EXT_d2i(ext);
if (constraints)
@@ -584,7 +597,10 @@ static bool parse_basicConstraints_ext(private_openssl_x509_t *this,
}
if (constraints->pathlen)
{
- this->pathlen = ASN1_INTEGER_get(constraints->pathlen);
+
+ pathlen = ASN1_INTEGER_get(constraints->pathlen);
+ this->pathlen = (pathlen >= 0 && pathlen < 128) ?
+ pathlen : X509_NO_CONSTRAINT;
}
BASIC_CONSTRAINTS_free(constraints);
return TRUE;
@@ -600,9 +616,10 @@ static bool parse_crlDistributionPoints_ext(private_openssl_x509_t *this,
{
CRL_DIST_POINTS *cdps;
DIST_POINT *cdp;
- identification_t *id;
+ identification_t *id, *issuer;
+ x509_cdp_t *entry;
char *uri;
- int i, j, point_num, name_num;
+ int i, j, k, point_num, name_num, issuer_num;
cdps = X509V3_EXT_d2i(ext);
if (!cdps)
@@ -627,12 +644,38 @@ static bool parse_crlDistributionPoints_ext(private_openssl_x509_t *this,
{
if (asprintf(&uri, "%Y", id) > 0)
{
- this->crl_uris->insert_first(this->crl_uris, uri);
+ if (cdp->CRLissuer)
+ {
+ issuer_num = sk_GENERAL_NAME_num(cdp->CRLissuer);
+ for (k = 0; k < issuer_num; k++)
+ {
+ issuer = general_name2id(
+ sk_GENERAL_NAME_value(cdp->CRLissuer, k));
+ if (issuer)
+ {
+ INIT(entry,
+ .uri = strdup(uri),
+ .issuer = issuer,
+ );
+ this->crl_uris->insert_last(
+ this->crl_uris, entry);
+ }
+ }
+ free(uri);
+ }
+ else
+ {
+ INIT(entry,
+ .uri = uri,
+ );
+ this->crl_uris->insert_last(this->crl_uris, entry);
+ }
}
id->destroy(id);
}
}
}
+
DIST_POINT_free(cdp);
}
}
@@ -765,7 +808,13 @@ static bool parse_extensions(private_openssl_x509_t *this)
ok = parse_crlDistributionPoints_ext(this, ext);
break;
default:
- ok = TRUE;
+ ok = X509_EXTENSION_get_critical(ext) == 0 ||
+ !lib->settings->get_bool(lib->settings,
+ "libstrongswan.x509.enforce_critical", TRUE);
+ if (!ok)
+ {
+ DBG1(DBG_LIB, "found unsupported critical X.509 extension");
+ }
break;
}
if (!ok)
@@ -823,6 +872,13 @@ static bool parse_certificate(private_openssl_x509_t *this)
{
return FALSE;
}
+ if (X509_get_version(this->x509) < 0 || X509_get_version(this->x509) > 2)
+ {
+ DBG1(DBG_LIB, "unsupported x509 version: %d",
+ X509_get_version(this->x509) + 1);
+ return FALSE;
+ }
+
this->subject = openssl_x509_name2id(X509_get_subject_name(this->x509));
this->issuer = openssl_x509_name2id(X509_get_issuer_name(this->x509));
@@ -866,7 +922,7 @@ static bool parse_certificate(private_openssl_x509_t *this)
if (!parse_extensions(this))
{
- return TRUE;
+ return FALSE;
}
parse_extKeyUsage(this);
diff --git a/src/libstrongswan/plugins/padlock/Makefile.in b/src/libstrongswan/plugins/padlock/Makefile.in
index 46953f681..7c89d0abd 100644
--- a/src/libstrongswan/plugins/padlock/Makefile.in
+++ b/src/libstrongswan/plugins/padlock/Makefile.in
@@ -222,9 +222,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -263,6 +261,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/padlock/padlock_plugin.c b/src/libstrongswan/plugins/padlock/padlock_plugin.c
index 027c53c7b..695823acf 100644
--- a/src/libstrongswan/plugins/padlock/padlock_plugin.c
+++ b/src/libstrongswan/plugins/padlock/padlock_plugin.c
@@ -23,6 +23,8 @@
#include <library.h>
#include <debug.h>
+static const char *plugin_name = "padlock";
+
typedef struct private_padlock_plugin_t private_padlock_plugin_t;
typedef enum padlock_feature_t padlock_feature_t;
@@ -161,21 +163,21 @@ plugin_t *padlock_plugin_create()
if (this->features & PADLOCK_RNG_ENABLED)
{
- lib->crypto->add_rng(lib->crypto, RNG_TRUE,
+ lib->crypto->add_rng(lib->crypto, RNG_TRUE, plugin_name,
(rng_constructor_t)padlock_rng_create);
- lib->crypto->add_rng(lib->crypto, RNG_STRONG,
+ lib->crypto->add_rng(lib->crypto, RNG_STRONG, plugin_name,
(rng_constructor_t)padlock_rng_create);
- lib->crypto->add_rng(lib->crypto, RNG_WEAK,
+ lib->crypto->add_rng(lib->crypto, RNG_WEAK, plugin_name,
(rng_constructor_t)padlock_rng_create);
}
if (this->features & PADLOCK_ACE2_ENABLED)
{
- lib->crypto->add_crypter(lib->crypto, ENCR_AES_CBC,
+ lib->crypto->add_crypter(lib->crypto, ENCR_AES_CBC, plugin_name,
(crypter_constructor_t)padlock_aes_crypter_create);
}
if (this->features & PADLOCK_PHE_ENABLED)
{
- lib->crypto->add_hasher(lib->crypto, HASH_SHA1,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA1, plugin_name,
(hasher_constructor_t)padlock_sha1_hasher_create);
}
return &this->public.plugin;
diff --git a/src/libstrongswan/plugins/pem/Makefile.in b/src/libstrongswan/plugins/pem/Makefile.in
index cf5acdd1c..60740eb35 100644
--- a/src/libstrongswan/plugins/pem/Makefile.in
+++ b/src/libstrongswan/plugins/pem/Makefile.in
@@ -220,9 +220,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -261,6 +259,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/pem/pem_encoder.c b/src/libstrongswan/plugins/pem/pem_encoder.c
index e255d6fd0..9c8237e4d 100644
--- a/src/libstrongswan/plugins/pem/pem_encoder.c
+++ b/src/libstrongswan/plugins/pem/pem_encoder.c
@@ -111,7 +111,7 @@ bool pem_encoder_encode(cred_encoding_type_t type, chunk_t *encoding,
}
/* compute and allocate maximum size of PEM object */
- pem_chars = 4*(asn1.len + 2)/3;
+ pem_chars = 4 * ((asn1.len + 2) / 3);
pem_lines = (asn1.len + BYTES_PER_LINE - 1) / BYTES_PER_LINE;
*encoding = chunk_alloc(5 + 2*(6 + strlen(label) + 6) + 3 + pem_chars + pem_lines);
pos = encoding->ptr;
diff --git a/src/libstrongswan/plugins/pem/pem_plugin.c b/src/libstrongswan/plugins/pem/pem_plugin.c
index 83efb155b..f2415a318 100644
--- a/src/libstrongswan/plugins/pem/pem_plugin.c
+++ b/src/libstrongswan/plugins/pem/pem_plugin.c
@@ -33,10 +33,8 @@ struct private_pem_plugin_t {
pem_plugin_t public;
};
-/**
- * Implementation of pem_plugin_t.pemtroy
- */
-static void destroy(private_pem_plugin_t *this)
+METHOD(plugin_t, destroy, void,
+ private_pem_plugin_t *this)
{
lib->creds->remove_builder(lib->creds,
(builder_function_t)pem_private_key_load);
@@ -52,9 +50,15 @@ static void destroy(private_pem_plugin_t *this)
*/
plugin_t *pem_plugin_create()
{
- private_pem_plugin_t *this = malloc_thing(private_pem_plugin_t);
-
- this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
+ private_pem_plugin_t *this;
+
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
/* register private key PEM decoding builders */
lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_ANY, FALSE,
diff --git a/src/libstrongswan/plugins/pgp/Makefile.in b/src/libstrongswan/plugins/pgp/Makefile.in
index 0098147a9..ab14f8ced 100644
--- a/src/libstrongswan/plugins/pgp/Makefile.in
+++ b/src/libstrongswan/plugins/pgp/Makefile.in
@@ -220,9 +220,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -261,6 +259,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/pgp/pgp_plugin.c b/src/libstrongswan/plugins/pgp/pgp_plugin.c
index 41e0a5df6..eaf0a1088 100644
--- a/src/libstrongswan/plugins/pgp/pgp_plugin.c
+++ b/src/libstrongswan/plugins/pgp/pgp_plugin.c
@@ -33,10 +33,8 @@ struct private_pgp_plugin_t {
pgp_plugin_t public;
};
-/**
- * Implementation of pgp_plugin_t.pgptroy
- */
-static void destroy(private_pgp_plugin_t *this)
+METHOD(plugin_t, destroy, void,
+ private_pgp_plugin_t *this)
{
lib->creds->remove_builder(lib->creds,
(builder_function_t)pgp_public_key_load);
@@ -56,10 +54,15 @@ static void destroy(private_pgp_plugin_t *this)
*/
plugin_t *pgp_plugin_create()
{
- private_pgp_plugin_t *this = malloc_thing(private_pgp_plugin_t);
-
- this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-
+ private_pgp_plugin_t *this;
+
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_ANY, FALSE,
(builder_function_t)pgp_public_key_load);
lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_RSA, FALSE,
@@ -68,10 +71,8 @@ plugin_t *pgp_plugin_create()
(builder_function_t)pgp_private_key_load);
lib->creds->add_builder(lib->creds, CRED_PRIVATE_KEY, KEY_RSA, FALSE,
(builder_function_t)pgp_private_key_load);
-
lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_GPG, FALSE,
(builder_function_t)pgp_cert_load);
-
lib->encoding->add_encoder(lib->encoding, pgp_encoder_encode);
return &this->public.plugin;
diff --git a/src/libstrongswan/plugins/pkcs1/Makefile.in b/src/libstrongswan/plugins/pkcs1/Makefile.in
index 8b41499a7..8ed4a08e9 100644
--- a/src/libstrongswan/plugins/pkcs1/Makefile.in
+++ b/src/libstrongswan/plugins/pkcs1/Makefile.in
@@ -221,9 +221,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -262,6 +260,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/pkcs1/pkcs1_plugin.c b/src/libstrongswan/plugins/pkcs1/pkcs1_plugin.c
index d3afb5c67..33732f8a4 100644
--- a/src/libstrongswan/plugins/pkcs1/pkcs1_plugin.c
+++ b/src/libstrongswan/plugins/pkcs1/pkcs1_plugin.c
@@ -32,10 +32,8 @@ struct private_pkcs1_plugin_t {
pkcs1_plugin_t public;
};
-/**
- * Implementation of pkcs1_plugin_t.pkcs1troy
- */
-static void destroy(private_pkcs1_plugin_t *this)
+METHOD(plugin_t, destroy, void,
+ private_pkcs1_plugin_t *this)
{
lib->creds->remove_builder(lib->creds,
(builder_function_t)pkcs1_public_key_load);
@@ -52,9 +50,15 @@ static void destroy(private_pkcs1_plugin_t *this)
*/
plugin_t *pkcs1_plugin_create()
{
- private_pkcs1_plugin_t *this = malloc_thing(private_pkcs1_plugin_t);
+ private_pkcs1_plugin_t *this;
- this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
lib->creds->add_builder(lib->creds, CRED_PUBLIC_KEY, KEY_ANY, FALSE,
(builder_function_t)pkcs1_public_key_load);
diff --git a/src/libstrongswan/plugins/pkcs11/Makefile.in b/src/libstrongswan/plugins/pkcs11/Makefile.in
index c27310910..6c03b0497 100644
--- a/src/libstrongswan/plugins/pkcs11/Makefile.in
+++ b/src/libstrongswan/plugins/pkcs11/Makefile.in
@@ -223,9 +223,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -264,6 +262,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/pkcs11/pkcs11_creds.c b/src/libstrongswan/plugins/pkcs11/pkcs11_creds.c
index 1b1448c6a..a81ec1147 100644
--- a/src/libstrongswan/plugins/pkcs11/pkcs11_creds.c
+++ b/src/libstrongswan/plugins/pkcs11/pkcs11_creds.c
@@ -55,19 +55,20 @@ struct private_pkcs11_creds_t {
* Find certificates, optionally trusted
*/
static void find_certificates(private_pkcs11_creds_t *this,
- CK_SESSION_HANDLE session, CK_BBOOL trusted)
+ CK_SESSION_HANDLE session)
{
CK_OBJECT_CLASS class = CKO_CERTIFICATE;
CK_CERTIFICATE_TYPE type = CKC_X_509;
+ CK_BBOOL trusted = TRUE;
CK_ATTRIBUTE tmpl[] = {
{CKA_CLASS, &class, sizeof(class)},
{CKA_CERTIFICATE_TYPE, &type, sizeof(type)},
- {CKA_TRUSTED, &trusted, sizeof(trusted)},
};
CK_OBJECT_HANDLE object;
CK_ATTRIBUTE attr[] = {
{CKA_VALUE, NULL, 0},
{CKA_LABEL, NULL, 0},
+ {CKA_TRUSTED, &trusted, sizeof(trusted)}
};
enumerator_t *enumerator;
linked_list_t *raw;
@@ -75,11 +76,19 @@ static void find_certificates(private_pkcs11_creds_t *this,
struct {
chunk_t value;
chunk_t label;
+ bool trusted;
} *entry;
+ int count = countof(attr);
+ /* store result in a temporary list, avoid recursive operation */
raw = linked_list_create();
+ /* do not use trusted argument if not supported */
+ if (!(this->lib->get_features(this->lib) & PKCS11_TRUSTED_CERTS))
+ {
+ count--;
+ }
enumerator = this->lib->create_object_enumerator(this->lib,
- session, tmpl, countof(tmpl), attr, countof(attr));
+ session, tmpl, countof(tmpl), attr, count);
while (enumerator->enumerate(enumerator, &object))
{
entry = malloc(sizeof(*entry));
@@ -87,6 +96,7 @@ static void find_certificates(private_pkcs11_creds_t *this,
chunk_create(attr[0].pValue, attr[0].ulValueLen));
entry->label = chunk_clone(
chunk_create(attr[1].pValue, attr[1].ulValueLen));
+ entry->trusted = trusted;
raw->insert_last(raw, entry);
}
enumerator->destroy(enumerator);
@@ -99,10 +109,10 @@ static void find_certificates(private_pkcs11_creds_t *this,
if (cert)
{
DBG1(DBG_CFG, " loaded %strusted cert '%.*s'",
- trusted ? "" : "un", entry->label.len, entry->label.ptr);
+ entry->trusted ? "" : "un", entry->label.len, entry->label.ptr);
/* trusted certificates are also returned as untrusted */
this->untrusted->insert_last(this->untrusted, cert);
- if (trusted)
+ if (entry->trusted)
{
this->trusted->insert_last(this->trusted, cert->get_ref(cert));
}
@@ -135,8 +145,7 @@ static bool load_certificates(private_pkcs11_creds_t *this)
return FALSE;
}
- find_certificates(this, session, CK_TRUE);
- find_certificates(this, session, CK_FALSE);
+ find_certificates(this, session);
this->lib->f->C_CloseSession(session);
return TRUE;
diff --git a/src/libstrongswan/plugins/pkcs11/pkcs11_library.c b/src/libstrongswan/plugins/pkcs11/pkcs11_library.c
index 9fb1b7769..6f7926808 100644
--- a/src/libstrongswan/plugins/pkcs11/pkcs11_library.c
+++ b/src/libstrongswan/plugins/pkcs11/pkcs11_library.c
@@ -466,6 +466,11 @@ struct private_pkcs11_library_t {
* Name as passed to the constructor
*/
char *name;
+
+ /**
+ * Supported feature set
+ */
+ pkcs11_feature_t features;
};
METHOD(pkcs11_library_t, get_name, char*,
@@ -474,6 +479,12 @@ METHOD(pkcs11_library_t, get_name, char*,
return this->name;
}
+METHOD(pkcs11_library_t, get_features, pkcs11_feature_t,
+ private_pkcs11_library_t *this)
+{
+ return this->features;
+}
+
/**
* Object enumerator
*/
@@ -766,19 +777,45 @@ static CK_RV UnlockMutex(CK_VOID_PTR data)
}
/**
+ * Check if the library has at least a given cryptoki version
+ */
+static bool has_version(CK_INFO *info, int major, int minor)
+{
+ return info->cryptokiVersion.major > major ||
+ (info->cryptokiVersion.major == major &&
+ info->cryptokiVersion.minor >= minor);
+}
+
+/**
+ * Check for optional PKCS#11 library functionality
+ */
+static void check_features(private_pkcs11_library_t *this, CK_INFO *info)
+{
+ if (has_version(info, 2, 20))
+ {
+ this->features |= PKCS11_TRUSTED_CERTS;
+ this->features |= PKCS11_ALWAYS_AUTH_KEYS;
+ }
+}
+
+/**
* Initialize a PKCS#11 library
*/
-static bool initialize(private_pkcs11_library_t *this, char *name, char *file)
+static bool initialize(private_pkcs11_library_t *this, char *name, char *file,
+ bool os_locking)
{
CK_C_GetFunctionList pC_GetFunctionList;
CK_INFO info;
CK_RV rv;
- CK_C_INITIALIZE_ARGS args = {
+ static CK_C_INITIALIZE_ARGS args = {
.CreateMutex = CreateMutex,
.DestroyMutex = DestroyMutex,
.LockMutex = LockMutex,
.UnlockMutex = UnlockMutex,
};
+ static CK_C_INITIALIZE_ARGS args_os = {
+ .flags = CKF_OS_LOCKING_OK,
+ };
pC_GetFunctionList = dlsym(this->handle, "C_GetFunctionList");
if (!pC_GetFunctionList)
@@ -793,14 +830,19 @@ static bool initialize(private_pkcs11_library_t *this, char *name, char *file)
name, ck_rv_names, rv);
return FALSE;
}
-
- rv = this->public.f->C_Initialize(&args);
- if (rv == CKR_CANT_LOCK)
- { /* try OS locking */
- memset(&args, 0, sizeof(args));
- args.flags = CKF_OS_LOCKING_OK;
+ if (os_locking)
+ {
+ rv = CKR_CANT_LOCK;
+ }
+ else
+ {
rv = this->public.f->C_Initialize(&args);
}
+ if (rv == CKR_CANT_LOCK)
+ { /* fallback to OS locking */
+ os_locking = TRUE;
+ rv = this->public.f->C_Initialize(&args_os);
+ }
if (rv != CKR_OK)
{
DBG1(DBG_CFG, "C_Initialize() error for '%s': %N",
@@ -826,23 +868,26 @@ static bool initialize(private_pkcs11_library_t *this, char *name, char *file)
DBG1(DBG_CFG, " %s: %s v%d.%d",
info.manufacturerID, info.libraryDescription,
info.libraryVersion.major, info.libraryVersion.minor);
- if (args.flags & CKF_OS_LOCKING_OK)
+ if (os_locking)
{
DBG1(DBG_CFG, " uses OS locking functions");
}
+
+ check_features(this, &info);
return TRUE;
}
/**
* See header
*/
-pkcs11_library_t *pkcs11_library_create(char *name, char *file)
+pkcs11_library_t *pkcs11_library_create(char *name, char *file, bool os_locking)
{
private_pkcs11_library_t *this;
INIT(this,
.public = {
.get_name = _get_name,
+ .get_features = _get_features,
.create_object_enumerator = _create_object_enumerator,
.create_mechanism_enumerator = _create_mechanism_enumerator,
.destroy = _destroy,
@@ -858,7 +903,7 @@ pkcs11_library_t *pkcs11_library_create(char *name, char *file)
return NULL;
}
- if (!initialize(this, name, file))
+ if (!initialize(this, name, file, os_locking))
{
dlclose(this->handle);
free(this);
diff --git a/src/libstrongswan/plugins/pkcs11/pkcs11_library.h b/src/libstrongswan/plugins/pkcs11/pkcs11_library.h
index 1457d24d4..abe023448 100644
--- a/src/libstrongswan/plugins/pkcs11/pkcs11_library.h
+++ b/src/libstrongswan/plugins/pkcs11/pkcs11_library.h
@@ -21,6 +21,7 @@
#ifndef PKCS11_LIBRARY_H_
#define PKCS11_LIBRARY_H_
+typedef enum pkcs11_feature_t pkcs11_feature_t;
typedef struct pkcs11_library_t pkcs11_library_t;
#include "pkcs11.h"
@@ -29,6 +30,16 @@ typedef struct pkcs11_library_t pkcs11_library_t;
#include <utils/enumerator.h>
/**
+ * Optional PKCS#11 features some libraries support, some not
+ */
+enum pkcs11_feature_t {
+ /** CKA_TRUSTED attribute supported for certificate objects */
+ PKCS11_TRUSTED_CERTS = (1<<0),
+ /** CKA_ALWAYS_AUTHENTICATE attribute supported for private keys */
+ PKCS11_ALWAYS_AUTH_KEYS = (1<<1),
+};
+
+/**
* A loaded and initialized PKCS#11 library.
*/
struct pkcs11_library_t {
@@ -46,6 +57,13 @@ struct pkcs11_library_t {
char* (*get_name)(pkcs11_library_t *this);
/**
+ * Get the feature set supported by this library.
+ *
+ * @return ORed set of features supported
+ */
+ pkcs11_feature_t (*get_features)(pkcs11_library_t *this);
+
+ /**
* Create an enumerator over CK_OBJECT_HANDLE using a search template.
*
* An optional attribute array is automatically filled in with the
@@ -103,8 +121,9 @@ void pkcs11_library_trim(char *str, int len);
*
* @param name an arbitrary name, for debugging
* @param file pkcs11 library file to dlopen()
+ * @param os_lock enforce OS Locking for this library
* @return library abstraction
*/
-pkcs11_library_t *pkcs11_library_create(char *name, char *file);
+pkcs11_library_t *pkcs11_library_create(char *name, char *file, bool os_lock);
#endif /** PKCS11_LIBRARY_H_ @}*/
diff --git a/src/libstrongswan/plugins/pkcs11/pkcs11_manager.c b/src/libstrongswan/plugins/pkcs11/pkcs11_manager.c
index 0c27600a6..9308e9c25 100644
--- a/src/libstrongswan/plugins/pkcs11/pkcs11_manager.c
+++ b/src/libstrongswan/plugins/pkcs11/pkcs11_manager.c
@@ -373,7 +373,10 @@ pkcs11_manager_t *pkcs11_manager_create(pkcs11_manager_token_event_t cb,
free(entry);
continue;
}
- entry->lib = pkcs11_library_create(module, entry->path);
+ entry->lib = pkcs11_library_create(module, entry->path,
+ lib->settings->get_bool(lib->settings,
+ "libstrongswan.plugins.pkcs11.modules.%s.os_locking",
+ FALSE, module));
if (!entry->lib)
{
free(entry);
diff --git a/src/libstrongswan/plugins/pkcs11/pkcs11_plugin.c b/src/libstrongswan/plugins/pkcs11/pkcs11_plugin.c
index ace405c23..071d2f782 100644
--- a/src/libstrongswan/plugins/pkcs11/pkcs11_plugin.c
+++ b/src/libstrongswan/plugins/pkcs11/pkcs11_plugin.c
@@ -26,6 +26,8 @@
#include "pkcs11_public_key.h"
#include "pkcs11_hasher.h"
+static const char *plugin_name = "pkcs11";
+
typedef struct private_pkcs11_plugin_t private_pkcs11_plugin_t;
/**
@@ -146,17 +148,17 @@ plugin_t *pkcs11_plugin_create()
if (lib->settings->get_bool(lib->settings,
"libstrongswan.plugins.pkcs11.use_hasher", FALSE))
{
- lib->crypto->add_hasher(lib->crypto, HASH_MD2,
+ lib->crypto->add_hasher(lib->crypto, HASH_MD2, plugin_name,
(hasher_constructor_t)pkcs11_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_MD5,
+ lib->crypto->add_hasher(lib->crypto, HASH_MD5, plugin_name,
(hasher_constructor_t)pkcs11_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_SHA1,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA1, plugin_name,
(hasher_constructor_t)pkcs11_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_SHA256,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA256, plugin_name,
(hasher_constructor_t)pkcs11_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_SHA384,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA384, plugin_name,
(hasher_constructor_t)pkcs11_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_SHA512,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA512, plugin_name,
(hasher_constructor_t)pkcs11_hasher_create);
}
diff --git a/src/libstrongswan/plugins/pkcs11/pkcs11_private_key.c b/src/libstrongswan/plugins/pkcs11/pkcs11_private_key.c
index cabca3f54..b4cc7a805 100644
--- a/src/libstrongswan/plugins/pkcs11/pkcs11_private_key.c
+++ b/src/libstrongswan/plugins/pkcs11/pkcs11_private_key.c
@@ -401,30 +401,36 @@ static bool find_key(private_pkcs11_private_key_t *this, chunk_t keyid)
};
CK_OBJECT_HANDLE object;
CK_KEY_TYPE type;
- CK_BBOOL reauth;
+ CK_BBOOL reauth = FALSE;
CK_ATTRIBUTE attr[] = {
{CKA_KEY_TYPE, &type, sizeof(type)},
- {CKA_ALWAYS_AUTHENTICATE, &reauth, sizeof(reauth)},
{CKA_MODULUS, NULL, 0},
{CKA_PUBLIC_EXPONENT, NULL, 0},
+ {CKA_ALWAYS_AUTHENTICATE, &reauth, sizeof(reauth)},
};
enumerator_t *enumerator;
chunk_t modulus, pubexp;
+ int count = countof(attr);
+ /* do not use CKA_ALWAYS_AUTHENTICATE if not supported */
+ if (!(this->lib->get_features(this->lib) & PKCS11_ALWAYS_AUTH_KEYS))
+ {
+ count--;
+ }
enumerator = this->lib->create_object_enumerator(this->lib,
- this->session, tmpl, countof(tmpl), attr, countof(attr));
+ this->session, tmpl, countof(tmpl), attr, count);
if (enumerator->enumerate(enumerator, &object))
{
switch (type)
{
case CKK_RSA:
- if (attr[2].ulValueLen == -1 || attr[3].ulValueLen == -1)
+ if (attr[1].ulValueLen == -1 || attr[2].ulValueLen == -1)
{
DBG1(DBG_CFG, "reading modulus/exponent from PKCS#1 failed");
break;
}
- modulus = chunk_create(attr[2].pValue, attr[2].ulValueLen);
- pubexp = chunk_create(attr[3].pValue, attr[3].ulValueLen);
+ modulus = chunk_create(attr[1].pValue, attr[1].ulValueLen);
+ pubexp = chunk_create(attr[2].pValue, attr[2].ulValueLen);
this->pubkey = lib->creds->create(lib->creds, CRED_PUBLIC_KEY,
KEY_RSA, BUILD_RSA_MODULUS, modulus,
BUILD_RSA_PUB_EXP, pubexp, BUILD_END);
diff --git a/src/libstrongswan/plugins/plugin_loader.c b/src/libstrongswan/plugins/plugin_loader.c
index e1427bf15..473db5ccf 100644
--- a/src/libstrongswan/plugins/plugin_loader.c
+++ b/src/libstrongswan/plugins/plugin_loader.c
@@ -50,62 +50,77 @@ struct private_plugin_loader_t {
linked_list_t *names;
};
-#ifdef MONOLITHIC
/**
- * load a single plugin in monolithic mode
+ * create a plugin
+ * returns: NOT_FOUND, if the constructor was not found
+ * FAILED, if the plugin could not be constructed
*/
-static plugin_t* load_plugin(private_plugin_loader_t *this,
- char *path, char *name)
+static status_t create_plugin(private_plugin_loader_t *this, void *handle,
+ char *name, bool integrity, plugin_t **plugin)
{
char create[128];
- plugin_t *plugin;
plugin_constructor_t constructor;
if (snprintf(create, sizeof(create), "%s_plugin_create",
name) >= sizeof(create))
{
- return NULL;
+ return FAILED;
}
translate(create, "-", "_");
- constructor = dlsym(RTLD_DEFAULT, create);
+ constructor = dlsym(handle, create);
if (constructor == NULL)
{
- DBG1(DBG_LIB, "plugin '%s': failed to load - %s not found", name,
+ DBG2(DBG_LIB, "plugin '%s': failed to load - %s not found", name,
create);
- return NULL;
+ return NOT_FOUND;
}
- plugin = constructor();
- if (plugin == NULL)
+ if (integrity && lib->integrity)
+ {
+ if (!lib->integrity->check_segment(lib->integrity, name, constructor))
+ {
+ DBG1(DBG_LIB, "plugin '%s': failed segment integrity test", name);
+ return FAILED;
+ }
+ DBG1(DBG_LIB, "plugin '%s': passed file and segment integrity tests",
+ name);
+ }
+ *plugin = constructor();
+ if (*plugin == NULL)
{
DBG1(DBG_LIB, "plugin '%s': failed to load - %s returned NULL", name,
create);
- return NULL;
+ return FAILED;
}
DBG2(DBG_LIB, "plugin '%s': loaded successfully", name);
-
- return plugin;
+ return SUCCESS;
}
-#else
+
/**
* load a single plugin
*/
static plugin_t* load_plugin(private_plugin_loader_t *this,
char *path, char *name)
{
- char create[128];
char file[PATH_MAX];
void *handle;
plugin_t *plugin;
- plugin_constructor_t constructor;
+
+ switch (create_plugin(this, RTLD_DEFAULT, name, FALSE, &plugin))
+ {
+ case SUCCESS:
+ return plugin;
+ case NOT_FOUND:
+ /* try to load the plugin from a file */
+ break;
+ default:
+ return NULL;
+ }
if (snprintf(file, sizeof(file), "%s/libstrongswan-%s.so", path,
- name) >= sizeof(file) ||
- snprintf(create, sizeof(create), "%s_plugin_create",
- name) >= sizeof(create))
+ name) >= sizeof(file))
{
return NULL;
}
- translate(create, "-", "_");
if (lib->integrity)
{
if (!lib->integrity->check_file(lib->integrity, name, file))
@@ -121,40 +136,37 @@ static plugin_t* load_plugin(private_plugin_loader_t *this,
DBG1(DBG_LIB, "plugin '%s' failed to load: %s", name, dlerror());
return NULL;
}
- constructor = dlsym(handle, create);
- if (constructor == NULL)
+ if (create_plugin(this, handle, name, TRUE, &plugin) != SUCCESS)
{
- DBG1(DBG_LIB, "plugin '%s': failed to load - %s not found", name,
- create);
dlclose(handle);
return NULL;
}
- if (lib->integrity)
+ /* we do not store or free dlopen() handles, leak_detective requires
+ * the modules to keep loaded until leak report */
+ return plugin;
+}
+
+/**
+ * Check if a plugin is already loaded
+ */
+static bool plugin_loaded(private_plugin_loader_t *this, char *name)
+{
+ enumerator_t *enumerator;
+ bool found = FALSE;
+ char *current;
+
+ enumerator = this->names->create_enumerator(this->names);
+ while (enumerator->enumerate(enumerator, &current))
{
- if (!lib->integrity->check_segment(lib->integrity, name, constructor))
+ if (streq(name, current))
{
- DBG1(DBG_LIB, "plugin '%s': failed segment integrity test", name);
- dlclose(handle);
- return NULL;
+ found = TRUE;
+ break;
}
- DBG1(DBG_LIB, "plugin '%s': passed file and segment integrity tests",
- name);
}
- plugin = constructor();
- if (plugin == NULL)
- {
- DBG1(DBG_LIB, "plugin '%s': failed to load - %s returned NULL", name,
- create);
- dlclose(handle);
- return NULL;
- }
- DBG2(DBG_LIB, "plugin '%s': loaded successfully", name);
-
- /* we do not store or free dlopen() handles, leak_detective requires
- * the modules to keep loaded until leak report */
- return plugin;
+ enumerator->destroy(enumerator);
+ return found;
}
-#endif
/**
* Implementation of plugin_loader_t.load_plugins.
@@ -165,12 +177,10 @@ static bool load(private_plugin_loader_t *this, char *path, char *list)
char *token;
bool critical_failed = FALSE;
-#ifndef MONOLITHIC
if (path == NULL)
{
path = PLUGINDIR;
}
-#endif
enumerator = enumerator_create_token(list, " ", " ");
while (!critical_failed && enumerator->enumerate(enumerator, &token))
@@ -186,6 +196,11 @@ static bool load(private_plugin_loader_t *this, char *path, char *list)
critical = TRUE;
token[len-1] = '\0';
}
+ if (plugin_loaded(this, token))
+ {
+ free(token);
+ continue;
+ }
plugin = load_plugin(this, path, token);
if (plugin)
{
diff --git a/src/libstrongswan/plugins/pubkey/Makefile.in b/src/libstrongswan/plugins/pubkey/Makefile.in
index 495223855..46349f9ba 100644
--- a/src/libstrongswan/plugins/pubkey/Makefile.in
+++ b/src/libstrongswan/plugins/pubkey/Makefile.in
@@ -221,9 +221,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -262,6 +260,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/pubkey/pubkey_plugin.c b/src/libstrongswan/plugins/pubkey/pubkey_plugin.c
index 6f41ada2a..cc12217a4 100644
--- a/src/libstrongswan/plugins/pubkey/pubkey_plugin.c
+++ b/src/libstrongswan/plugins/pubkey/pubkey_plugin.c
@@ -31,10 +31,8 @@ struct private_pubkey_plugin_t {
pubkey_plugin_t public;
};
-/**
- * Implementation of pubkey_plugin_t.pubkeytroy
- */
-static void destroy(private_pubkey_plugin_t *this)
+METHOD(plugin_t, destroy, void,
+ private_pubkey_plugin_t *this)
{
lib->creds->remove_builder(lib->creds,
(builder_function_t)pubkey_cert_wrap);
@@ -46,9 +44,15 @@ static void destroy(private_pubkey_plugin_t *this)
*/
plugin_t *pubkey_plugin_create()
{
- private_pubkey_plugin_t *this = malloc_thing(private_pubkey_plugin_t);
-
- this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
+ private_pubkey_plugin_t *this;
+
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_TRUSTED_PUBKEY, FALSE,
(builder_function_t)pubkey_cert_wrap);
diff --git a/src/libstrongswan/plugins/random/Makefile.in b/src/libstrongswan/plugins/random/Makefile.in
index efd24c761..21f8aff11 100644
--- a/src/libstrongswan/plugins/random/Makefile.in
+++ b/src/libstrongswan/plugins/random/Makefile.in
@@ -221,9 +221,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -262,6 +260,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/random/random_plugin.c b/src/libstrongswan/plugins/random/random_plugin.c
index 39678ba71..cc5cb0a3c 100644
--- a/src/libstrongswan/plugins/random/random_plugin.c
+++ b/src/libstrongswan/plugins/random/random_plugin.c
@@ -18,6 +18,8 @@
#include <library.h>
#include "random_rng.h"
+static const char *plugin_name = "random";
+
typedef struct private_random_plugin_t private_random_plugin_t;
/**
@@ -31,10 +33,8 @@ struct private_random_plugin_t {
random_plugin_t public;
};
-/**
- * Implementation of random_plugin_t.gmptroy
- */
-static void destroy(private_random_plugin_t *this)
+METHOD(plugin_t, destroy, void,
+ private_random_plugin_t *this)
{
lib->crypto->remove_rng(lib->crypto,
(rng_constructor_t)random_rng_create);
@@ -46,13 +46,19 @@ static void destroy(private_random_plugin_t *this)
*/
plugin_t *random_plugin_create()
{
- private_random_plugin_t *this = malloc_thing(private_random_plugin_t);
+ private_random_plugin_t *this;
- this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
- lib->crypto->add_rng(lib->crypto, RNG_STRONG,
+ lib->crypto->add_rng(lib->crypto, RNG_STRONG, plugin_name,
(rng_constructor_t)random_rng_create);
- lib->crypto->add_rng(lib->crypto, RNG_TRUE,
+ lib->crypto->add_rng(lib->crypto, RNG_TRUE, plugin_name,
(rng_constructor_t)random_rng_create);
return &this->public.plugin;
diff --git a/src/libstrongswan/plugins/random/random_rng.c b/src/libstrongswan/plugins/random/random_rng.c
index b09f3f57a..1d99a63d5 100644
--- a/src/libstrongswan/plugins/random/random_rng.c
+++ b/src/libstrongswan/plugins/random/random_rng.c
@@ -55,11 +55,8 @@ struct private_random_rng_t {
char *file;
};
-/**
- * Implementation of random_rng_t.get_bytes.
- */
-static void get_bytes(private_random_rng_t *this, size_t bytes,
- u_int8_t *buffer)
+METHOD(rng_t, get_bytes, void,
+ private_random_rng_t *this, size_t bytes, u_int8_t *buffer)
{
size_t done;
ssize_t got;
@@ -81,20 +78,15 @@ static void get_bytes(private_random_rng_t *this, size_t bytes,
}
}
-/**
- * Implementation of random_rng_t.allocate_bytes.
- */
-static void allocate_bytes(private_random_rng_t *this, size_t bytes,
- chunk_t *chunk)
+METHOD(rng_t, allocate_bytes, void,
+ private_random_rng_t *this, size_t bytes, chunk_t *chunk)
{
*chunk = chunk_alloc(bytes);
get_bytes(this, chunk->len, chunk->ptr);
}
-/**
- * Implementation of random_rng_t.destroy.
- */
-static void destroy(private_random_rng_t *this)
+METHOD(rng_t, destroy, void,
+ private_random_rng_t *this)
{
close(this->dev);
free(this);
@@ -105,12 +97,17 @@ static void destroy(private_random_rng_t *this)
*/
random_rng_t *random_rng_create(rng_quality_t quality)
{
- private_random_rng_t *this = malloc_thing(private_random_rng_t);
-
- /* public functions */
- this->public.rng.get_bytes = (void (*) (rng_t *, size_t, u_int8_t*)) get_bytes;
- this->public.rng.allocate_bytes = (void (*) (rng_t *, size_t, chunk_t*)) allocate_bytes;
- this->public.rng.destroy = (void (*) (rng_t *))destroy;
+ private_random_rng_t *this;
+
+ INIT(this,
+ .public = {
+ .rng = {
+ .get_bytes = _get_bytes,
+ .allocate_bytes = _allocate_bytes,
+ .destroy = _destroy,
+ },
+ },
+ );
if (quality == RNG_TRUE)
{
diff --git a/src/libstrongswan/plugins/revocation/Makefile.in b/src/libstrongswan/plugins/revocation/Makefile.in
index 16a9d21c5..4ed4b9694 100644
--- a/src/libstrongswan/plugins/revocation/Makefile.in
+++ b/src/libstrongswan/plugins/revocation/Makefile.in
@@ -223,9 +223,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -264,6 +262,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/revocation/revocation_validator.c b/src/libstrongswan/plugins/revocation/revocation_validator.c
index 29d2bc128..def169275 100644
--- a/src/libstrongswan/plugins/revocation/revocation_validator.c
+++ b/src/libstrongswan/plugins/revocation/revocation_validator.c
@@ -93,12 +93,13 @@ static certificate_t *fetch_ocsp(char *url, certificate_t *subject,
/**
* check the signature of an OCSP response
*/
-static bool verify_ocsp(ocsp_response_t *response)
+static bool verify_ocsp(ocsp_response_t *response, auth_cfg_t *auth)
{
certificate_t *issuer, *subject;
identification_t *responder;
ocsp_response_wrapper_t *wrapper;
enumerator_t *enumerator;
+ auth_cfg_t *current;
bool verified = FALSE;
wrapper = ocsp_response_wrapper_create((ocsp_response_t*)response);
@@ -108,12 +109,16 @@ static bool verify_ocsp(ocsp_response_t *response)
responder = subject->get_issuer(subject);
enumerator = lib->credmgr->create_trusted_enumerator(lib->credmgr,
KEY_ANY, responder, FALSE);
- while (enumerator->enumerate(enumerator, &issuer, NULL))
+ while (enumerator->enumerate(enumerator, &issuer, &current))
{
if (lib->credmgr->issued_by(lib->credmgr, subject, issuer))
{
DBG1(DBG_CFG, " ocsp response correctly signed by \"%Y\"",
issuer->get_subject(issuer));
+ if (auth)
+ {
+ auth->merge(auth, current, FALSE);
+ }
verified = TRUE;
break;
}
@@ -129,7 +134,8 @@ static bool verify_ocsp(ocsp_response_t *response)
* Get the better of two OCSP responses, and check for usable OCSP info
*/
static certificate_t *get_better_ocsp(certificate_t *cand, certificate_t *best,
- x509_t *subject, x509_t *issuer, cert_validation_t *valid, bool cache)
+ x509_t *subject, x509_t *issuer, cert_validation_t *valid,
+ auth_cfg_t *auth, bool cache)
{
ocsp_response_t *response;
time_t revocation, this_update, next_update, valid_until;
@@ -139,7 +145,7 @@ static certificate_t *get_better_ocsp(certificate_t *cand, certificate_t *best,
response = (ocsp_response_t*)cand;
/* check ocsp signature */
- if (!verify_ocsp(response))
+ if (!verify_ocsp(response, auth))
{
DBG1(DBG_CFG, "ocsp response verification failed");
cand->destroy(cand);
@@ -220,7 +226,8 @@ static cert_validation_t check_ocsp(x509_t *subject, x509_t *issuer,
while (enumerator->enumerate(enumerator, &current))
{
current->get_ref(current);
- best = get_better_ocsp(current, best, subject, issuer, &valid, FALSE);
+ best = get_better_ocsp(current, best, subject, issuer,
+ &valid, auth, FALSE);
if (best && valid != VALIDATION_STALE)
{
DBG1(DBG_CFG, " using cached ocsp response");
@@ -247,7 +254,7 @@ static cert_validation_t check_ocsp(x509_t *subject, x509_t *issuer,
if (current)
{
best = get_better_ocsp(current, best, subject, issuer,
- &valid, TRUE);
+ &valid, auth, TRUE);
if (best && valid != VALIDATION_STALE)
{
break;
@@ -269,7 +276,7 @@ static cert_validation_t check_ocsp(x509_t *subject, x509_t *issuer,
if (current)
{
best = get_better_ocsp(current, best, subject, issuer,
- &valid, TRUE);
+ &valid, auth, TRUE);
if (best && valid != VALIDATION_STALE)
{
break;
@@ -323,20 +330,25 @@ static certificate_t* fetch_crl(char *url)
/**
* check the signature of an CRL
*/
-static bool verify_crl(certificate_t *crl)
+static bool verify_crl(certificate_t *crl, auth_cfg_t *auth)
{
certificate_t *issuer;
enumerator_t *enumerator;
bool verified = FALSE;
+ auth_cfg_t *current;
enumerator = lib->credmgr->create_trusted_enumerator(lib->credmgr,
KEY_ANY, crl->get_issuer(crl), FALSE);
- while (enumerator->enumerate(enumerator, &issuer, NULL))
+ while (enumerator->enumerate(enumerator, &issuer, &current))
{
if (lib->credmgr->issued_by(lib->credmgr, crl, issuer))
{
DBG1(DBG_CFG, " crl correctly signed by \"%Y\"",
issuer->get_subject(issuer));
+ if (auth)
+ {
+ auth->merge(auth, current, FALSE);
+ }
verified = TRUE;
break;
}
@@ -350,23 +362,41 @@ static bool verify_crl(certificate_t *crl)
* Get the better of two CRLs, and check for usable CRL info
*/
static certificate_t *get_better_crl(certificate_t *cand, certificate_t *best,
- x509_t *subject, x509_t *issuer, cert_validation_t *valid, bool cache)
+ x509_t *subject, cert_validation_t *valid, auth_cfg_t *auth,
+ bool cache, crl_t *base)
{
enumerator_t *enumerator;
time_t revocation, valid_until;
crl_reason_t reason;
chunk_t serial;
- crl_t *crl;
+ crl_t *crl = (crl_t*)cand;
+
+ if (base)
+ {
+ if (!crl->is_delta_crl(crl, &serial) ||
+ !chunk_equals(serial, base->get_serial(base)))
+ {
+ cand->destroy(cand);
+ return best;
+ }
+ }
+ else
+ {
+ if (crl->is_delta_crl(crl, NULL))
+ {
+ cand->destroy(cand);
+ return best;
+ }
+ }
/* check CRL signature */
- if (!verify_crl(cand))
+ if (!verify_crl(cand, auth))
{
DBG1(DBG_CFG, "crl response verification failed");
cand->destroy(cand);
return best;
}
- crl = (crl_t*)cand;
enumerator = crl->create_enumerator(crl);
while (enumerator->enumerate(enumerator, &serial, &revocation, &reason))
{
@@ -411,79 +441,191 @@ static certificate_t *get_better_crl(certificate_t *cand, certificate_t *best,
}
/**
- * validate a x509 certificate using CRL
+ * Find or fetch a certificate for a given crlIssuer
*/
-static cert_validation_t check_crl(x509_t *subject, x509_t *issuer,
- auth_cfg_t *auth)
+static cert_validation_t find_crl(x509_t *subject, identification_t *issuer,
+ auth_cfg_t *auth, crl_t *base,
+ certificate_t **best, bool *uri_found)
{
cert_validation_t valid = VALIDATION_SKIPPED;
- identification_t *keyid = NULL;
- certificate_t *best = NULL;
+ enumerator_t *enumerator;
certificate_t *current;
- public_key_t *public;
+ char *uri;
+
+ /* find a cached (delta) crl */
+ enumerator = lib->credmgr->create_cert_enumerator(lib->credmgr,
+ CERT_X509_CRL, KEY_ANY, issuer, FALSE);
+ while (enumerator->enumerate(enumerator, &current))
+ {
+ current->get_ref(current);
+ *best = get_better_crl(current, *best, subject, &valid,
+ auth, FALSE, base);
+ if (*best && valid != VALIDATION_STALE)
+ {
+ DBG1(DBG_CFG, " using cached crl");
+ break;
+ }
+ }
+ enumerator->destroy(enumerator);
+
+ /* fallback to fetching crls from credential sets cdps */
+ if (!base && valid != VALIDATION_GOOD && valid != VALIDATION_REVOKED)
+ {
+ enumerator = lib->credmgr->create_cdp_enumerator(lib->credmgr,
+ CERT_X509_CRL, issuer);
+ while (enumerator->enumerate(enumerator, &uri))
+ {
+ *uri_found = TRUE;
+ current = fetch_crl(uri);
+ if (current)
+ {
+ if (!current->has_issuer(current, issuer))
+ {
+ DBG1(DBG_CFG, "issuer of fetched CRL '%Y' does not match CRL "
+ "issuer '%Y'", current->get_issuer(current), issuer);
+ current->destroy(current);
+ continue;
+ }
+ *best = get_better_crl(current, *best, subject,
+ &valid, auth, TRUE, base);
+ if (*best && valid != VALIDATION_STALE)
+ {
+ break;
+ }
+ }
+ }
+ enumerator->destroy(enumerator);
+ }
+ return valid;
+}
+
+/**
+ * Look for a delta CRL for a given base CRL
+ */
+static cert_validation_t check_delta_crl(x509_t *subject, x509_t *issuer,
+ crl_t *base, cert_validation_t base_valid, auth_cfg_t *auth)
+{
+ cert_validation_t valid = VALIDATION_SKIPPED;
+ certificate_t *best = NULL, *current;
enumerator_t *enumerator;
+ identification_t *id;
+ x509_cdp_t *cdp;
chunk_t chunk;
- char *uri = NULL;
+ bool uri;
- /* derive the authorityKeyIdentifier from the issuer's public key */
- current = &issuer->interface;
- public = current->get_public_key(current);
- if (public && public->get_fingerprint(public, KEYID_PUBKEY_SHA1, &chunk))
+ /* find cached delta CRL via subjectKeyIdentifier */
+ chunk = issuer->get_subjectKeyIdentifier(issuer);
+ if (chunk.len)
{
- keyid = identification_create_from_encoding(ID_KEY_ID, chunk);
+ id = identification_create_from_encoding(ID_KEY_ID, chunk);
+ valid = find_crl(subject, id, auth, base, &best, &uri);
+ id->destroy(id);
+ }
- /* find a cached crl by authorityKeyIdentifier */
- enumerator = lib->credmgr->create_cert_enumerator(lib->credmgr,
- CERT_X509_CRL, KEY_ANY, keyid, FALSE);
- while (enumerator->enumerate(enumerator, &current))
+ /* find delta CRL by CRLIssuer */
+ enumerator = subject->create_crl_uri_enumerator(subject);
+ while (valid != VALIDATION_GOOD && valid != VALIDATION_REVOKED &&
+ enumerator->enumerate(enumerator, &cdp))
+ {
+ if (cdp->issuer)
{
- current->get_ref(current);
- best = get_better_crl(current, best, subject, issuer,
- &valid, FALSE);
+ valid = find_crl(subject, cdp->issuer, auth, base, &best, &uri);
+ }
+ }
+ enumerator->destroy(enumerator);
+
+ /* fetch from URIs found in Freshest CRL extension */
+ enumerator = base->create_delta_crl_uri_enumerator(base);
+ while (valid != VALIDATION_GOOD && valid != VALIDATION_REVOKED &&
+ enumerator->enumerate(enumerator, &cdp))
+ {
+ current = fetch_crl(cdp->uri);
+ if (current)
+ {
+ if (cdp->issuer && !current->has_issuer(current, cdp->issuer))
+ {
+ DBG1(DBG_CFG, "issuer of fetched delta CRL '%Y' does not match "
+ "certificates CRL issuer '%Y'",
+ current->get_issuer(current), cdp->issuer);
+ current->destroy(current);
+ continue;
+ }
+ best = get_better_crl(current, best, subject, &valid,
+ auth, TRUE, base);
if (best && valid != VALIDATION_STALE)
{
- DBG1(DBG_CFG, " using cached crl");
break;
}
}
- enumerator->destroy(enumerator);
+ }
+ enumerator->destroy(enumerator);
+
+ if (best)
+ {
+ best->destroy(best);
+ return valid;
+ }
+ return base_valid;
+}
+
+
+/**
+ * validate a x509 certificate using CRL
+ */
+static cert_validation_t check_crl(x509_t *subject, x509_t *issuer,
+ auth_cfg_t *auth)
+{
+ cert_validation_t valid = VALIDATION_SKIPPED;
+ certificate_t *best = NULL;
+ identification_t *id;
+ x509_cdp_t *cdp;
+ bool uri_found = FALSE;
+ certificate_t *current;
+ enumerator_t *enumerator;
+ chunk_t chunk;
+
+ /* use issuers subjectKeyIdentifier to find a cached CRL / fetch from CDP */
+ chunk = issuer->get_subjectKeyIdentifier(issuer);
+ if (chunk.len)
+ {
+ id = identification_create_from_encoding(ID_KEY_ID, chunk);
+ valid = find_crl(subject, id, auth, NULL, &best, &uri_found);
+ id->destroy(id);
+ }
- /* fallback to fetching crls from credential sets cdps */
- if (valid != VALIDATION_GOOD && valid != VALIDATION_REVOKED)
+ /* find a cached CRL or fetch via configured CDP via CRLIssuer */
+ enumerator = subject->create_crl_uri_enumerator(subject);
+ while (valid != VALIDATION_GOOD && valid != VALIDATION_REVOKED &&
+ enumerator->enumerate(enumerator, &cdp))
+ {
+ if (cdp->issuer)
{
- enumerator = lib->credmgr->create_cdp_enumerator(lib->credmgr,
- CERT_X509_CRL, keyid);
- while (enumerator->enumerate(enumerator, &uri))
- {
- current = fetch_crl(uri);
- if (current)
- {
- best = get_better_crl(current, best, subject, issuer,
- &valid, TRUE);
- if (best && valid != VALIDATION_STALE)
- {
- break;
- }
- }
- }
- enumerator->destroy(enumerator);
+ valid = find_crl(subject, cdp->issuer, auth, NULL,
+ &best, &uri_found);
}
- keyid->destroy(keyid);
}
- DESTROY_IF(public);
+ enumerator->destroy(enumerator);
- /* fallback to fetching crls from cdps from subject's certificate */
+ /* fallback to fetching CRLs from CDPs found in subjects certificate */
if (valid != VALIDATION_GOOD && valid != VALIDATION_REVOKED)
{
enumerator = subject->create_crl_uri_enumerator(subject);
-
- while (enumerator->enumerate(enumerator, &uri))
+ while (enumerator->enumerate(enumerator, &cdp))
{
- current = fetch_crl(uri);
+ uri_found = TRUE;
+ current = fetch_crl(cdp->uri);
if (current)
{
- best = get_better_crl(current, best, subject, issuer,
- &valid, TRUE);
+ if (cdp->issuer && !current->has_issuer(current, cdp->issuer))
+ {
+ DBG1(DBG_CFG, "issuer of fetched CRL '%Y' does not match "
+ "certificates CRL issuer '%Y'",
+ current->get_issuer(current), cdp->issuer);
+ current->destroy(current);
+ continue;
+ }
+ best = get_better_crl(current, best, subject, &valid,
+ auth, TRUE, NULL);
if (best && valid != VALIDATION_STALE)
{
break;
@@ -493,8 +635,14 @@ static cert_validation_t check_crl(x509_t *subject, x509_t *issuer,
enumerator->destroy(enumerator);
}
+ /* look for delta CRLs */
+ if (best && (valid == VALIDATION_GOOD || valid == VALIDATION_STALE))
+ {
+ valid = check_delta_crl(subject, issuer, (crl_t*)best, valid, auth);
+ }
+
/* an uri was found, but no result. switch validation state to failed */
- if (valid == VALIDATION_SKIPPED && uri)
+ if (valid == VALIDATION_SKIPPED && uri_found)
{
valid = VALIDATION_FAILED;
}
@@ -517,7 +665,8 @@ static cert_validation_t check_crl(x509_t *subject, x509_t *issuer,
METHOD(cert_validator_t, validate, bool,
private_revocation_validator_t *this, certificate_t *subject,
- certificate_t *issuer, bool online, int pathlen, auth_cfg_t *auth)
+ certificate_t *issuer, bool online, u_int pathlen, bool anchor,
+ auth_cfg_t *auth)
{
if (subject->get_type(subject) == CERT_X509 &&
issuer->get_type(issuer) == CERT_X509 &&
@@ -525,7 +674,8 @@ METHOD(cert_validator_t, validate, bool,
{
DBG1(DBG_CFG, "checking certificate status of \"%Y\"",
subject->get_subject(subject));
- switch (check_ocsp((x509_t*)subject, (x509_t*)issuer, auth))
+ switch (check_ocsp((x509_t*)subject, (x509_t*)issuer,
+ pathlen ? NULL : auth))
{
case VALIDATION_GOOD:
DBG1(DBG_CFG, "certificate status is good");
@@ -543,7 +693,8 @@ METHOD(cert_validator_t, validate, bool,
DBG1(DBG_CFG, "ocsp check failed, fallback to crl");
break;
}
- switch (check_crl((x509_t*)subject, (x509_t*)issuer, auth))
+ switch (check_crl((x509_t*)subject, (x509_t*)issuer,
+ pathlen ? NULL : auth))
{
case VALIDATION_GOOD:
DBG1(DBG_CFG, "certificate status is good");
diff --git a/src/libstrongswan/plugins/sha1/Makefile.in b/src/libstrongswan/plugins/sha1/Makefile.in
index 1036bedfc..3d96f4339 100644
--- a/src/libstrongswan/plugins/sha1/Makefile.in
+++ b/src/libstrongswan/plugins/sha1/Makefile.in
@@ -220,9 +220,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -261,6 +259,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/sha1/sha1_plugin.c b/src/libstrongswan/plugins/sha1/sha1_plugin.c
index 7b9cf878f..dda2cbc1a 100644
--- a/src/libstrongswan/plugins/sha1/sha1_plugin.c
+++ b/src/libstrongswan/plugins/sha1/sha1_plugin.c
@@ -19,6 +19,8 @@
#include "sha1_hasher.h"
#include "sha1_prf.h"
+static const char *plugin_name = "sha1";
+
typedef struct private_sha1_plugin_t private_sha1_plugin_t;
/**
@@ -32,10 +34,8 @@ struct private_sha1_plugin_t {
sha1_plugin_t public;
};
-/**
- * Implementation of sha1_plugin_t.destroy
- */
-static void destroy(private_sha1_plugin_t *this)
+METHOD(plugin_t, destroy, void,
+ private_sha1_plugin_t *this)
{
lib->crypto->remove_hasher(lib->crypto,
(hasher_constructor_t)sha1_hasher_create);
@@ -49,13 +49,19 @@ static void destroy(private_sha1_plugin_t *this)
*/
plugin_t *sha1_plugin_create()
{
- private_sha1_plugin_t *this = malloc_thing(private_sha1_plugin_t);
+ private_sha1_plugin_t *this;
- this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
- lib->crypto->add_hasher(lib->crypto, HASH_SHA1,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA1, plugin_name,
(hasher_constructor_t)sha1_hasher_create);
- lib->crypto->add_prf(lib->crypto, PRF_KEYED_SHA1,
+ lib->crypto->add_prf(lib->crypto, PRF_KEYED_SHA1, plugin_name,
(prf_constructor_t)sha1_prf_create);
return &this->public.plugin;
diff --git a/src/libstrongswan/plugins/sha2/Makefile.in b/src/libstrongswan/plugins/sha2/Makefile.in
index 579e6f9b0..fcbfa0c44 100644
--- a/src/libstrongswan/plugins/sha2/Makefile.in
+++ b/src/libstrongswan/plugins/sha2/Makefile.in
@@ -219,9 +219,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -260,6 +258,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/sha2/sha2_plugin.c b/src/libstrongswan/plugins/sha2/sha2_plugin.c
index 810d9922a..a5937dbb2 100644
--- a/src/libstrongswan/plugins/sha2/sha2_plugin.c
+++ b/src/libstrongswan/plugins/sha2/sha2_plugin.c
@@ -18,6 +18,8 @@
#include <library.h>
#include "sha2_hasher.h"
+static const char *plugin_name = "sha2";
+
typedef struct private_sha2_plugin_t private_sha2_plugin_t;
/**
@@ -31,10 +33,8 @@ struct private_sha2_plugin_t {
sha2_plugin_t public;
};
-/**
- * Implementation of sha2_plugin_t.destroy
- */
-static void destroy(private_sha2_plugin_t *this)
+METHOD(plugin_t, destroy, void,
+ private_sha2_plugin_t *this)
{
lib->crypto->remove_hasher(lib->crypto,
(hasher_constructor_t)sha2_hasher_create);
@@ -46,17 +46,23 @@ static void destroy(private_sha2_plugin_t *this)
*/
plugin_t *sha2_plugin_create()
{
- private_sha2_plugin_t *this = malloc_thing(private_sha2_plugin_t);
+ private_sha2_plugin_t *this;
- this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
- lib->crypto->add_hasher(lib->crypto, HASH_SHA224,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA224, plugin_name,
(hasher_constructor_t)sha2_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_SHA256,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA256, plugin_name,
(hasher_constructor_t)sha2_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_SHA384,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA384, plugin_name,
(hasher_constructor_t)sha2_hasher_create);
- lib->crypto->add_hasher(lib->crypto, HASH_SHA512,
+ lib->crypto->add_hasher(lib->crypto, HASH_SHA512, plugin_name,
(hasher_constructor_t)sha2_hasher_create);
return &this->public.plugin;
diff --git a/src/libstrongswan/plugins/soup/Makefile.am b/src/libstrongswan/plugins/soup/Makefile.am
new file mode 100644
index 000000000..9006f1b7c
--- /dev/null
+++ b/src/libstrongswan/plugins/soup/Makefile.am
@@ -0,0 +1,16 @@
+
+INCLUDES = -I$(top_srcdir)/src/libstrongswan ${soup_CFLAGS}
+
+AM_CFLAGS = -rdynamic
+
+if MONOLITHIC
+noinst_LTLIBRARIES = libstrongswan-soup.la
+else
+plugin_LTLIBRARIES = libstrongswan-soup.la
+endif
+
+libstrongswan_soup_la_SOURCES = \
+ soup_plugin.h soup_plugin.c soup_fetcher.c soup_fetcher.h
+
+libstrongswan_soup_la_LDFLAGS = -module -avoid-version
+libstrongswan_soup_la_LIBADD = ${soup_LIBS}
diff --git a/src/libstrongswan/plugins/soup/Makefile.in b/src/libstrongswan/plugins/soup/Makefile.in
new file mode 100644
index 000000000..35d175f95
--- /dev/null
+++ b/src/libstrongswan/plugins/soup/Makefile.in
@@ -0,0 +1,601 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/libstrongswan/plugins/soup
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/config/libtool.m4 \
+ $(top_srcdir)/m4/config/ltoptions.m4 \
+ $(top_srcdir)/m4/config/ltsugar.m4 \
+ $(top_srcdir)/m4/config/ltversion.m4 \
+ $(top_srcdir)/m4/config/lt~obsolete.m4 \
+ $(top_srcdir)/m4/macros/with.m4 \
+ $(top_srcdir)/m4/macros/enable-disable.m4 \
+ $(top_srcdir)/m4/macros/add-plugin.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(plugindir)"
+LTLIBRARIES = $(noinst_LTLIBRARIES) $(plugin_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libstrongswan_soup_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am_libstrongswan_soup_la_OBJECTS = soup_plugin.lo soup_fetcher.lo
+libstrongswan_soup_la_OBJECTS = $(am_libstrongswan_soup_la_OBJECTS)
+libstrongswan_soup_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(libstrongswan_soup_la_LDFLAGS) $(LDFLAGS) -o $@
+@MONOLITHIC_FALSE@am_libstrongswan_soup_la_rpath = -rpath $(plugindir)
+@MONOLITHIC_TRUE@am_libstrongswan_soup_la_rpath =
+DEFAULT_INCLUDES = -I.@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libstrongswan_soup_la_SOURCES)
+DIST_SOURCES = $(libstrongswan_soup_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BTLIB = @BTLIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLIB = @DLLIB@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GPERF = @GPERF@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MYSQLCFLAG = @MYSQLCFLAG@
+MYSQLCONFIG = @MYSQLCONFIG@
+MYSQLLIB = @MYSQLLIB@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PTHREADLIB = @PTHREADLIB@
+RANLIB = @RANLIB@
+RTLIB = @RTLIB@
+RUBY = @RUBY@
+RUBYINCLUDE = @RUBYINCLUDE@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOCKLIB = @SOCKLIB@
+STRIP = @STRIP@
+VERSION = @VERSION@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+c_plugins = @c_plugins@
+datadir = @datadir@
+datarootdir = @datarootdir@
+dbusservicedir = @dbusservicedir@
+default_pkcs11 = @default_pkcs11@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+gtk_CFLAGS = @gtk_CFLAGS@
+gtk_LIBS = @gtk_LIBS@
+h_plugins = @h_plugins@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+ipsecdir = @ipsecdir@
+ipsecgroup = @ipsecgroup@
+ipsecuser = @ipsecuser@
+libcharon_plugins = @libcharon_plugins@
+libdir = @libdir@
+libexecdir = @libexecdir@
+linux_headers = @linux_headers@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+maemo_CFLAGS = @maemo_CFLAGS@
+maemo_LIBS = @maemo_LIBS@
+manager_plugins = @manager_plugins@
+mandir = @mandir@
+medsrv_plugins = @medsrv_plugins@
+mkdir_p = @mkdir_p@
+nm_CFLAGS = @nm_CFLAGS@
+nm_LIBS = @nm_LIBS@
+nm_ca_dir = @nm_ca_dir@
+oldincludedir = @oldincludedir@
+openac_plugins = @openac_plugins@
+p_plugins = @p_plugins@
+pdfdir = @pdfdir@
+piddir = @piddir@
+pki_plugins = @pki_plugins@
+plugindir = @plugindir@
+pluto_plugins = @pluto_plugins@
+pool_plugins = @pool_plugins@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+random_device = @random_device@
+resolv_conf = @resolv_conf@
+routing_table = @routing_table@
+routing_table_prio = @routing_table_prio@
+s_plugins = @s_plugins@
+sbindir = @sbindir@
+scepclient_plugins = @scepclient_plugins@
+scripts_plugins = @scripts_plugins@
+sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
+srcdir = @srcdir@
+strongswan_conf = @strongswan_conf@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+urandom_device = @urandom_device@
+xml_CFLAGS = @xml_CFLAGS@
+xml_LIBS = @xml_LIBS@
+INCLUDES = -I$(top_srcdir)/src/libstrongswan ${soup_CFLAGS}
+AM_CFLAGS = -rdynamic
+@MONOLITHIC_TRUE@noinst_LTLIBRARIES = libstrongswan-soup.la
+@MONOLITHIC_FALSE@plugin_LTLIBRARIES = libstrongswan-soup.la
+libstrongswan_soup_la_SOURCES = \
+ soup_plugin.h soup_plugin.c soup_fetcher.c soup_fetcher.h
+
+libstrongswan_soup_la_LDFLAGS = -module -avoid-version
+libstrongswan_soup_la_LIBADD = ${soup_LIBS}
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/libstrongswan/plugins/soup/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/libstrongswan/plugins/soup/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(plugindir)" || $(MKDIR_P) "$(DESTDIR)$(plugindir)"
+ @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \
+ }
+
+uninstall-pluginLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \
+ done
+
+clean-pluginLTLIBRARIES:
+ -test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES)
+ @list='$(plugin_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libstrongswan-soup.la: $(libstrongswan_soup_la_OBJECTS) $(libstrongswan_soup_la_DEPENDENCIES)
+ $(libstrongswan_soup_la_LINK) $(am_libstrongswan_soup_la_rpath) $(libstrongswan_soup_la_OBJECTS) $(libstrongswan_soup_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/soup_fetcher.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/soup_plugin.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(plugindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ clean-pluginLTLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pluginLTLIBRARIES
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pluginLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLTLIBRARIES clean-pluginLTLIBRARIES \
+ ctags distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-pluginLTLIBRARIES install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am \
+ uninstall-pluginLTLIBRARIES
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/libstrongswan/plugins/soup/soup_fetcher.c b/src/libstrongswan/plugins/soup/soup_fetcher.c
new file mode 100644
index 000000000..fd97631bd
--- /dev/null
+++ b/src/libstrongswan/plugins/soup/soup_fetcher.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include "soup_fetcher.h"
+
+#include <libsoup/soup.h>
+
+#include <library.h>
+#include <debug.h>
+
+#define DEFAULT_TIMEOUT 10
+
+typedef struct private_soup_fetcher_t private_soup_fetcher_t;
+
+/**
+ * private data of a soup_fetcher_t object.
+ */
+struct private_soup_fetcher_t {
+
+ /**
+ * Public data
+ */
+ soup_fetcher_t public;
+
+ /**
+ * HTTP request method
+ */
+ const char *method;
+
+ /**
+ * Request content type
+ */
+ char *type;
+
+ /**
+ * Request data
+ */
+ chunk_t data;
+
+ /**
+ * Request timeout
+ */
+ u_int timeout;
+
+ /**
+ * HTTP request version
+ */
+ SoupHTTPVersion version;
+};
+
+METHOD(fetcher_t, fetch, status_t,
+ private_soup_fetcher_t *this, char *uri, chunk_t *result)
+{
+ SoupSession *session;
+ SoupMessage *message;
+ status_t status = FAILED;
+
+ message = soup_message_new(this->method, uri);
+ if (!message)
+ {
+ return NOT_SUPPORTED;
+ }
+ if (this->type)
+ {
+ soup_message_set_request(message, this->type, SOUP_MEMORY_STATIC,
+ this->data.ptr, this->data.len);
+ }
+ soup_message_set_http_version(message, this->version);
+ session = soup_session_sync_new();
+ g_object_set(G_OBJECT(session),
+ SOUP_SESSION_TIMEOUT, (guint)this->timeout, NULL);
+
+ DBG2(DBG_LIB, "sending http request to '%s'...", uri);
+ soup_session_send_message(session, message);
+ if (SOUP_STATUS_IS_SUCCESSFUL(message->status_code))
+ {
+ *result = chunk_clone(chunk_create((u_char*)message->response_body->data,
+ message->response_body->length));
+ status = SUCCESS;
+ }
+ else
+ {
+ DBG1(DBG_LIB, "HTTP request failed, code %d", message->status_code);
+ }
+ g_object_unref(G_OBJECT(message));
+ g_object_unref(G_OBJECT(session));
+ return status;
+}
+
+METHOD(fetcher_t, set_option, bool,
+ private_soup_fetcher_t *this, fetcher_option_t option, ...)
+{
+ bool supported = TRUE;
+ va_list args;
+
+ va_start(args, option);
+ switch (option)
+ {
+ case FETCH_REQUEST_DATA:
+ this->method = SOUP_METHOD_POST;
+ this->data = va_arg(args, chunk_t);
+ break;
+ case FETCH_REQUEST_TYPE:
+ this->type = va_arg(args, char*);
+ break;
+ case FETCH_HTTP_VERSION_1_0:
+ this->version = SOUP_HTTP_1_0;
+ break;
+ case FETCH_TIMEOUT:
+ this->timeout = va_arg(args, u_int);
+ break;
+ default:
+ supported = FALSE;
+ break;
+ }
+ va_end(args);
+ return supported;
+}
+
+METHOD(fetcher_t, destroy, void,
+ private_soup_fetcher_t *this)
+{
+ free(this);
+}
+
+/*
+ * Described in header.
+ */
+soup_fetcher_t *soup_fetcher_create()
+{
+ private_soup_fetcher_t *this;
+
+ INIT(this,
+ .public = {
+ .interface = {
+ .fetch = _fetch,
+ .set_option = _set_option,
+ .destroy = _destroy,
+ },
+ },
+ .method = SOUP_METHOD_GET,
+ .version = SOUP_HTTP_1_1,
+ .timeout = DEFAULT_TIMEOUT,
+ );
+
+ return &this->public;
+}
diff --git a/src/libstrongswan/plugins/soup/soup_fetcher.h b/src/libstrongswan/plugins/soup/soup_fetcher.h
new file mode 100644
index 000000000..9b2579515
--- /dev/null
+++ b/src/libstrongswan/plugins/soup/soup_fetcher.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup soup_fetcher soup_fetcher
+ * @{ @ingroup soup_p
+ */
+
+#ifndef SOUP_FETCHER_H_
+#define SOUP_FETCHER_H_
+
+#include <library.h>
+
+typedef struct soup_fetcher_t soup_fetcher_t;
+
+/**
+ * Fetcher implementation for HTTP using libsoup.
+ */
+struct soup_fetcher_t {
+
+ /**
+ * Implements fetcher interface.
+ */
+ fetcher_t interface;
+};
+
+/**
+ * Create a soup_fetcher instance.
+ */
+soup_fetcher_t *soup_fetcher_create();
+
+#endif /** SOUP_FETCHER_H_ @}*/
diff --git a/src/libstrongswan/plugins/soup/soup_plugin.c b/src/libstrongswan/plugins/soup/soup_plugin.c
new file mode 100644
index 000000000..970e32472
--- /dev/null
+++ b/src/libstrongswan/plugins/soup/soup_plugin.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include "soup_plugin.h"
+#include "soup_fetcher.h"
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <library.h>
+
+typedef struct private_soup_plugin_t private_soup_plugin_t;
+
+/**
+ * private data of soup_plugin
+ */
+struct private_soup_plugin_t {
+
+ /**
+ * public functions
+ */
+ soup_plugin_t public;
+};
+
+METHOD(plugin_t, destroy, void,
+ private_soup_plugin_t *this)
+{
+ lib->fetcher->remove_fetcher(lib->fetcher,
+ (fetcher_constructor_t)soup_fetcher_create);
+ free(this);
+}
+
+/*
+ * see header file
+ */
+plugin_t *soup_plugin_create()
+{
+ private_soup_plugin_t *this;
+
+ g_type_init();
+ if (!g_thread_get_initialized())
+ {
+ g_thread_init(NULL);
+ }
+
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
+
+ lib->fetcher->add_fetcher(lib->fetcher,
+ (fetcher_constructor_t)soup_fetcher_create, "http://");
+ lib->fetcher->add_fetcher(lib->fetcher,
+ (fetcher_constructor_t)soup_fetcher_create, "https://");
+
+ return &this->public.plugin;
+}
diff --git a/src/libstrongswan/credentials/certificates/x509.c b/src/libstrongswan/plugins/soup/soup_plugin.h
index 66dc192c1..2dfa1d243 100644
--- a/src/libstrongswan/credentials/certificates/x509.c
+++ b/src/libstrongswan/plugins/soup/soup_plugin.h
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2008 Martin Willi
- * Hochschule fuer Technik Rapperswil
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -13,16 +13,30 @@
* for more details.
*/
-#include "x509.h"
+/**
+ * @defgroup soup_p soup
+ * @ingroup plugins
+ *
+ * @defgroup soup_plugin soup_plugin
+ * @{ @ingroup soup_p
+ */
+
+#ifndef SOUP_PLUGIN_H_
+#define SOUP_PLUGIN_H_
+
+#include <plugins/plugin.h>
+
+typedef struct soup_plugin_t soup_plugin_t;
+
+/**
+ * Plugin implementing fetcher interface for HTTP using libsoup.
+ */
+struct soup_plugin_t {
-ENUM(x509_flag_names, X509_NONE, X509_IP_ADDR_BLOCKS,
- "X509_NONE",
- "X509_CA",
- "X509_AA",
- "X509_OCSP_SIGNER",
- "X509_SERVER_AUTH",
- "X509_CLIENT_AUTH",
- "X509_SELF_SIGNED",
- "X509_IP_ADDR_BLOCKS",
-);
+ /**
+ * Implements plugin interface
+ */
+ plugin_t plugin;
+};
+#endif /** SOUP_PLUGIN_H_ @}*/
diff --git a/src/libstrongswan/plugins/sqlite/Makefile.in b/src/libstrongswan/plugins/sqlite/Makefile.in
index 9c9b57f98..ae015d1a8 100644
--- a/src/libstrongswan/plugins/sqlite/Makefile.in
+++ b/src/libstrongswan/plugins/sqlite/Makefile.in
@@ -222,9 +222,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -263,6 +261,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/sqlite/sqlite_database.c b/src/libstrongswan/plugins/sqlite/sqlite_database.c
index 3e20dbb51..f9e06199e 100644
--- a/src/libstrongswan/plugins/sqlite/sqlite_database.c
+++ b/src/libstrongswan/plugins/sqlite/sqlite_database.c
@@ -213,10 +213,8 @@ static bool sqlite_enumerator_enumerate(sqlite_enumerator_t *this, ...)
return TRUE;
}
-/**
- * Implementation of database_t.query.
- */
-static enumerator_t* query(private_sqlite_database_t *this, char *sql, ...)
+METHOD(database_t, query, enumerator_t*,
+ private_sqlite_database_t *this, char *sql, ...)
{
sqlite3_stmt *stmt;
va_list args;
@@ -248,10 +246,8 @@ static enumerator_t* query(private_sqlite_database_t *this, char *sql, ...)
return (enumerator_t*)enumerator;
}
-/**
- * Implementation of database_t.execute.
- */
-static int execute(private_sqlite_database_t *this, int *rowid, char *sql, ...)
+METHOD(database_t, execute, int,
+ private_sqlite_database_t *this, int *rowid, char *sql, ...)
{
sqlite3_stmt *stmt;
int affected = -1;
@@ -283,10 +279,8 @@ static int execute(private_sqlite_database_t *this, int *rowid, char *sql, ...)
return affected;
}
-/**
- * Implementation of database_t.get_driver
- */
-static db_driver_t get_driver(private_sqlite_database_t *this)
+METHOD(database_t, get_driver, db_driver_t,
+ private_sqlite_database_t *this)
{
return DB_SQLITE;
}
@@ -302,10 +296,8 @@ static int busy_handler(private_sqlite_database_t *this, int count)
return 1;
}
-/**
- * Implementation of database_t.destroy
- */
-static void destroy(private_sqlite_database_t *this)
+METHOD(database_t, destroy, void,
+ private_sqlite_database_t *this)
{
sqlite3_close(this->db);
this->mutex->destroy(this->mutex);
@@ -329,20 +321,23 @@ sqlite_database_t *sqlite_database_create(char *uri)
}
file = uri + 9;
- this = malloc_thing(private_sqlite_database_t);
-
- this->public.db.query = (enumerator_t* (*)(database_t *this, char *sql, ...))query;
- this->public.db.execute = (int (*)(database_t *this, int *rowid, char *sql, ...))execute;
- this->public.db.get_driver = (db_driver_t(*)(database_t*))get_driver;
- this->public.db.destroy = (void(*)(database_t*))destroy;
-
- this->mutex = mutex_create(MUTEX_TYPE_RECURSIVE);
+ INIT(this,
+ .public = {
+ .db = {
+ .query = _query,
+ .execute = _execute,
+ .get_driver = _get_driver,
+ .destroy = _destroy,
+ },
+ },
+ .mutex = mutex_create(MUTEX_TYPE_RECURSIVE),
+ );
if (sqlite3_open(file, &this->db) != SQLITE_OK)
{
DBG1(DBG_LIB, "opening SQLite database '%s' failed: %s",
file, sqlite3_errmsg(this->db));
- destroy(this);
+ _destroy(this);
return NULL;
}
diff --git a/src/libstrongswan/plugins/sqlite/sqlite_plugin.c b/src/libstrongswan/plugins/sqlite/sqlite_plugin.c
index 332d82318..e0b8e6ce1 100644
--- a/src/libstrongswan/plugins/sqlite/sqlite_plugin.c
+++ b/src/libstrongswan/plugins/sqlite/sqlite_plugin.c
@@ -31,10 +31,8 @@ struct private_sqlite_plugin_t {
sqlite_plugin_t public;
};
-/**
- * Implementation of plugin_t.destroy
- */
-static void destroy(private_sqlite_plugin_t *this)
+METHOD(plugin_t, destroy, void,
+ private_sqlite_plugin_t *this)
{
lib->db->remove_database(lib->db,
(database_constructor_t)sqlite_database_create);
@@ -46,9 +44,15 @@ static void destroy(private_sqlite_plugin_t *this)
*/
plugin_t *sqlite_plugin_create()
{
- private_sqlite_plugin_t *this = malloc_thing(private_sqlite_plugin_t);
-
- this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
+ private_sqlite_plugin_t *this;
+
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
lib->db->add_database(lib->db,
(database_constructor_t)sqlite_database_create);
diff --git a/src/libstrongswan/plugins/test_vectors/Makefile.in b/src/libstrongswan/plugins/test_vectors/Makefile.in
index 9be3f825a..9dccb05e3 100644
--- a/src/libstrongswan/plugins/test_vectors/Makefile.in
+++ b/src/libstrongswan/plugins/test_vectors/Makefile.in
@@ -227,9 +227,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -268,6 +266,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/test_vectors/test_vectors_plugin.c b/src/libstrongswan/plugins/test_vectors/test_vectors_plugin.c
index f3a254d8d..176bc438d 100644
--- a/src/libstrongswan/plugins/test_vectors/test_vectors_plugin.c
+++ b/src/libstrongswan/plugins/test_vectors/test_vectors_plugin.c
@@ -104,10 +104,8 @@ struct private_test_vectors_plugin_t {
test_vectors_plugin_t public;
};
-/**
- * Implementation of test_vectors_plugin_t.test_vectorstroy
- */
-static void destroy(private_test_vectors_plugin_t *this)
+METHOD(plugin_t, destroy, void,
+ private_test_vectors_plugin_t *this)
{
free(this);
}
@@ -117,10 +115,16 @@ static void destroy(private_test_vectors_plugin_t *this)
*/
plugin_t *test_vectors_plugin_create()
{
- private_test_vectors_plugin_t *this = malloc_thing(private_test_vectors_plugin_t);
+ private_test_vectors_plugin_t *this;
int i;
- this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
for (i = 0; i < countof(crypter); i++)
{
diff --git a/src/libstrongswan/plugins/x509/Makefile.in b/src/libstrongswan/plugins/x509/Makefile.in
index b1cc2f168..57deab98e 100644
--- a/src/libstrongswan/plugins/x509/Makefile.in
+++ b/src/libstrongswan/plugins/x509/Makefile.in
@@ -221,9 +221,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -262,6 +260,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/x509/x509_cert.c b/src/libstrongswan/plugins/x509/x509_cert.c
index 559090aa0..526dbe8c6 100644
--- a/src/libstrongswan/plugins/x509/x509_cert.c
+++ b/src/libstrongswan/plugins/x509/x509_cert.c
@@ -117,7 +117,7 @@ struct private_x509_cert_t {
linked_list_t *subjectAltNames;
/**
- * List of crlDistributionPoints as allocated char*
+ * List of crlDistributionPoints as x509_cdp_t*
*/
linked_list_t *crl_uris;
@@ -132,6 +132,26 @@ struct private_x509_cert_t {
linked_list_t *ipAddrBlocks;
/**
+ * List of permitted name constraints
+ */
+ linked_list_t *permitted_names;
+
+ /**
+ * List of exluced name constraints
+ */
+ linked_list_t *excluded_names;
+
+ /**
+ * List of certificatePolicies, as x509_cert_policy_t
+ */
+ linked_list_t *cert_policies;
+
+ /**
+ * List of policyMappings, as x509_policy_mapping_t
+ */
+ linked_list_t *policy_mappings;
+
+ /**
* certificate's embedded public key
*/
public_key_t *public_key;
@@ -154,7 +174,22 @@ struct private_x509_cert_t {
/**
* Path Length Constraint
*/
- int pathLenConstraint;
+ u_char pathLenConstraint;
+
+ /**
+ * requireExplicitPolicy Constraint
+ */
+ u_char require_explicit;
+
+ /**
+ * inhibitPolicyMapping Constraint
+ */
+ u_char inhibit_mapping;
+
+ /**
+ * inhibitAnyPolicy Constraint
+ */
+ u_char inhibit_any;
/**
* x509 constraints and other flags
@@ -187,6 +222,53 @@ static const chunk_t ASN1_subjectAltName_oid = chunk_from_chars(
);
/**
+ * Destroy a CertificateDistributionPoint
+ */
+static void crl_uri_destroy(x509_cdp_t *this)
+{
+ free(this->uri);
+ DESTROY_IF(this->issuer);
+ free(this);
+}
+
+/**
+ * Destroy a CertificatePolicy
+ */
+static void cert_policy_destroy(x509_cert_policy_t *this)
+{
+ free(this->oid.ptr);
+ free(this->cps_uri);
+ free(this->unotice_text);
+ free(this);
+}
+
+/**
+ * Free policy mapping
+ */
+static void policy_mapping_destroy(x509_policy_mapping_t *mapping)
+{
+ free(mapping->issuer.ptr);
+ free(mapping->subject.ptr);
+ free(mapping);
+}
+
+/**
+ * Parse a length constraint from an unwrapped integer
+ */
+static u_int parse_constraint(chunk_t object)
+{
+ switch (object.len)
+ {
+ case 0:
+ return 0;
+ case 1:
+ return (object.ptr[0] & 0x80) ? X509_NO_CONSTRAINT : object.ptr[0];
+ default:
+ return X509_NO_CONSTRAINT;
+ }
+}
+
+/**
* ASN.1 definition of a basicConstraints extension
*/
static const asn1Object_t basicConstraintsObjects[] = {
@@ -228,15 +310,7 @@ static void parse_basicConstraints(chunk_t blob, int level0,
case BASIC_CONSTRAINTS_PATH_LEN:
if (isCA)
{
- if (object.len == 0)
- {
- this->pathLenConstraint = 0;
- }
- else if (object.len == 1)
- {
- this->pathLenConstraint = *object.ptr;
- }
- /* we ignore path length constraints > 127 */
+ this->pathLenConstraint = parse_constraint(object);
}
break;
default:
@@ -574,7 +648,7 @@ static void parse_authorityInfoAccess(chunk_t blob, int level0,
}
break;
default:
- /* unkown accessMethod, ignoring */
+ /* unknown accessMethod, ignoring */
break;
}
break;
@@ -589,6 +663,60 @@ end:
}
/**
+ * Extract KeyUsage flags
+ */
+static void parse_keyUsage(chunk_t blob, private_x509_cert_t *this)
+{
+ enum {
+ KU_DIGITAL_SIGNATURE = 0,
+ KU_NON_REPUDIATION = 1,
+ KU_KEY_ENCIPHERMENT = 2,
+ KU_DATA_ENCIPHERMENT = 3,
+ KU_KEY_AGREEMENT = 4,
+ KU_KEY_CERT_SIGN = 5,
+ KU_CRL_SIGN = 6,
+ KU_ENCIPHER_ONLY = 7,
+ KU_DECIPHER_ONLY = 8,
+ };
+
+ if (asn1_unwrap(&blob, &blob) == ASN1_BIT_STRING && blob.len)
+ {
+ int bit, byte, unused = blob.ptr[0];
+
+ blob = chunk_skip(blob, 1);
+ for (byte = 0; byte < blob.len; byte++)
+ {
+ for (bit = 0; bit < 8; bit++)
+ {
+ if (byte == blob.len - 1 && bit > (7 - unused))
+ {
+ break;
+ }
+ if (blob.ptr[byte] & 1 << (7 - bit))
+ {
+ switch (byte * 8 + bit)
+ {
+ case KU_CRL_SIGN:
+ this->flags |= X509_CRL_SIGN;
+ break;
+ case KU_KEY_CERT_SIGN:
+ /* we use the caBasicConstraint, MUST be set */
+ case KU_DIGITAL_SIGNATURE:
+ case KU_NON_REPUDIATION:
+ case KU_KEY_ENCIPHERMENT:
+ case KU_DATA_ENCIPHERMENT:
+ case KU_KEY_AGREEMENT:
+ case KU_ENCIPHER_ONLY:
+ case KU_DECIPHER_ONLY:
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
+/**
* ASN.1 definition of a extendedKeyUsage extension
*/
static const asn1Object_t extendedKeyUsageObjects[] = {
@@ -600,7 +728,7 @@ static const asn1Object_t extendedKeyUsageObjects[] = {
#define EXT_KEY_USAGE_PURPOSE_ID 1
/**
- * Extracts extendedKeyUsage OIDs - currently only OCSP_SIGING is returned
+ * Extracts extendedKeyUsage OIDs
*/
static void parse_extendedKeyUsage(chunk_t blob, int level0,
private_x509_cert_t *this)
@@ -649,51 +777,328 @@ static const asn1Object_t crlDistributionPointsObjects[] = {
{ 2, "end opt", ASN1_EOC, ASN1_END }, /* 7 */
{ 2, "reasons", ASN1_CONTEXT_C_1, ASN1_OPT|ASN1_BODY }, /* 8 */
{ 2, "end opt", ASN1_EOC, ASN1_END }, /* 9 */
- { 2, "crlIssuer", ASN1_CONTEXT_C_2, ASN1_OPT|ASN1_BODY }, /* 10 */
+ { 2, "crlIssuer", ASN1_CONTEXT_C_2, ASN1_OPT|ASN1_OBJ }, /* 10 */
{ 2, "end opt", ASN1_EOC, ASN1_END }, /* 11 */
{ 0, "end loop", ASN1_EOC, ASN1_END }, /* 12 */
{ 0, "exit", ASN1_EOC, ASN1_EXIT }
};
+#define CRL_DIST_POINTS 1
#define CRL_DIST_POINTS_FULLNAME 3
+#define CRL_DIST_POINTS_ISSUER 10
+
+/**
+ * Add entry to the list of each pairing of URI and Issuer
+ */
+static void add_cdps(linked_list_t *list, linked_list_t *uris,
+ linked_list_t *issuers)
+{
+ identification_t *issuer, *id;
+ enumerator_t *enumerator;
+ x509_cdp_t *cdp;
+ char *uri;
+
+ while (uris->remove_last(uris, (void**)&id) == SUCCESS)
+ {
+ if (asprintf(&uri, "%Y", id) > 0)
+ {
+ if (issuers->get_count(issuers))
+ {
+ enumerator = issuers->create_enumerator(issuers);
+ while (enumerator->enumerate(enumerator, &issuer))
+ {
+ INIT(cdp,
+ .uri = strdup(uri),
+ .issuer = issuer->clone(issuer),
+ );
+ list->insert_last(list, cdp);
+ }
+ enumerator->destroy(enumerator);
+ free(uri);
+ }
+ else
+ {
+ INIT(cdp,
+ .uri = uri,
+ );
+ list->insert_last(list, cdp);
+ }
+ }
+ id->destroy(id);
+ }
+ while (issuers->remove_last(issuers, (void**)&id) == SUCCESS)
+ {
+ id->destroy(id);
+ }
+}
/**
* Extracts one or several crlDistributionPoints into a list
*/
-static void parse_crlDistributionPoints(chunk_t blob, int level0,
- private_x509_cert_t *this)
+void x509_parse_crlDistributionPoints(chunk_t blob, int level0,
+ linked_list_t *list)
{
+ linked_list_t *uris, *issuers;
asn1_parser_t *parser;
chunk_t object;
int objectID;
- linked_list_t *list = linked_list_create();
+ uris = linked_list_create();
+ issuers = linked_list_create();
parser = asn1_parser_create(crlDistributionPointsObjects, blob);
parser->set_top_level(parser, level0);
while (parser->iterate(parser, &objectID, &object))
{
- if (objectID == CRL_DIST_POINTS_FULLNAME)
+ switch (objectID)
{
- identification_t *id;
+ case CRL_DIST_POINTS:
+ add_cdps(list, uris, issuers);
+ break;
+ case CRL_DIST_POINTS_FULLNAME:
+ x509_parse_generalNames(object, parser->get_level(parser) + 1,
+ TRUE, uris);
+ break;
+ case CRL_DIST_POINTS_ISSUER:
+ x509_parse_generalNames(object, parser->get_level(parser) + 1,
+ TRUE, issuers);
+ break;
+ default:
+ break;
+ }
+ }
+ parser->destroy(parser);
- /* append extracted generalNames to existing chained list */
- x509_parse_generalNames(object, parser->get_level(parser)+1,
- TRUE, list);
+ add_cdps(list, uris, issuers);
- while (list->remove_last(list, (void**)&id) == SUCCESS)
- {
- char *uri;
+ uris->destroy(uris);
+ issuers->destroy(issuers);
+}
+
+/**
+ * ASN.1 definition of nameConstraints
+ */
+static const asn1Object_t nameConstraintsObjects[] = {
+ { 0, "nameConstraints", ASN1_SEQUENCE, ASN1_LOOP }, /* 0 */
+ { 1, "permittedSubtrees", ASN1_CONTEXT_C_0, ASN1_OPT|ASN1_LOOP }, /* 1 */
+ { 2, "generalSubtree", ASN1_SEQUENCE, ASN1_BODY }, /* 2 */
+ { 1, "end loop", ASN1_EOC, ASN1_END }, /* 3 */
+ { 1, "excludedSubtrees", ASN1_CONTEXT_C_1, ASN1_OPT|ASN1_LOOP }, /* 4 */
+ { 2, "generalSubtree", ASN1_SEQUENCE, ASN1_BODY }, /* 5 */
+ { 1, "end loop", ASN1_EOC, ASN1_END }, /* 6 */
+ { 0, "end loop", ASN1_EOC, ASN1_END }, /* 7 */
+ { 0, "exit", ASN1_EOC, ASN1_EXIT }
+};
+#define NAME_CONSTRAINT_PERMITTED 2
+#define NAME_CONSTRAINT_EXCLUDED 5
+
+/**
+ * Parse permitted/excluded nameConstraints
+ */
+static void parse_nameConstraints(chunk_t blob, int level0,
+ private_x509_cert_t *this)
+{
+ asn1_parser_t *parser;
+ identification_t *id;
+ chunk_t object;
+ int objectID;
+
+ parser = asn1_parser_create(nameConstraintsObjects, blob);
+ parser->set_top_level(parser, level0);
- if (asprintf(&uri, "%Y", id) > 0)
+ while (parser->iterate(parser, &objectID, &object))
+ {
+ switch (objectID)
+ {
+ case NAME_CONSTRAINT_PERMITTED:
+ id = parse_generalName(object, parser->get_level(parser) + 1);
+ if (id)
{
- this->crl_uris->insert_last(this->crl_uris, uri);
+ this->permitted_names->insert_last(this->permitted_names, id);
}
- id->destroy(id);
- }
+ break;
+ case NAME_CONSTRAINT_EXCLUDED:
+ id = parse_generalName(object, parser->get_level(parser) + 1);
+ if (id)
+ {
+ this->excluded_names->insert_last(this->excluded_names, id);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ parser->destroy(parser);
+}
+
+/**
+ * ASN.1 definition of a certificatePolicies extension
+ */
+static const asn1Object_t certificatePoliciesObject[] = {
+ { 0, "certificatePolicies", ASN1_SEQUENCE, ASN1_LOOP }, /* 0 */
+ { 1, "policyInformation", ASN1_SEQUENCE, ASN1_NONE }, /* 1 */
+ { 2, "policyId", ASN1_OID, ASN1_BODY }, /* 2 */
+ { 2, "qualifier", ASN1_SEQUENCE, ASN1_OPT|ASN1_BODY }, /* 3 */
+ { 3, "qualifierInfo", ASN1_SEQUENCE, ASN1_NONE }, /* 4 */
+ { 4, "qualifierId", ASN1_OID, ASN1_BODY }, /* 5 */
+ { 4, "cPSuri", ASN1_IA5STRING, ASN1_OPT|ASN1_BODY }, /* 6 */
+ { 4, "end choice", ASN1_EOC, ASN1_END }, /* 7 */
+ { 4, "userNotice", ASN1_SEQUENCE, ASN1_OPT|ASN1_NONE }, /* 8 */
+ { 5, "explicitText", ASN1_EOC, ASN1_RAW }, /* 9 */
+ { 4, "end choice", ASN1_EOC, ASN1_END }, /* 10 */
+ { 2, "end opt", ASN1_EOC, ASN1_END }, /* 12 */
+ { 0, "end loop", ASN1_EOC, ASN1_END }, /* 13 */
+ { 0, "exit", ASN1_EOC, ASN1_EXIT }
+};
+#define CERT_POLICY_ID 2
+#define CERT_POLICY_QUALIFIER_ID 5
+#define CERT_POLICY_CPS_URI 6
+#define CERT_POLICY_EXPLICIT_TEXT 9
+
+/**
+ * Parse certificatePolicies
+ */
+static void parse_certificatePolicies(chunk_t blob, int level0,
+ private_x509_cert_t *this)
+{
+ x509_cert_policy_t *policy = NULL;
+ asn1_parser_t *parser;
+ chunk_t object;
+ int objectID, qualifier = OID_UNKNOWN;
+
+ parser = asn1_parser_create(certificatePoliciesObject, blob);
+ parser->set_top_level(parser, level0);
+
+ while (parser->iterate(parser, &objectID, &object))
+ {
+ switch (objectID)
+ {
+ case CERT_POLICY_ID:
+ INIT(policy,
+ .oid = chunk_clone(object),
+ );
+ this->cert_policies->insert_last(this->cert_policies, policy);
+ break;
+ case CERT_POLICY_QUALIFIER_ID:
+ qualifier = asn1_known_oid(object);
+ break;
+ case CERT_POLICY_CPS_URI:
+ if (policy && !policy->cps_uri && object.len &&
+ qualifier == OID_POLICY_QUALIFIER_CPS &&
+ chunk_printable(object, NULL, 0))
+ {
+ policy->cps_uri = strndup(object.ptr, object.len);
+ }
+ break;
+ case CERT_POLICY_EXPLICIT_TEXT:
+ /* TODO */
+ break;
+ default:
+ break;
+ }
+ }
+ parser->destroy(parser);
+}
+
+/**
+ * ASN.1 definition of a policyMappings extension
+ */
+static const asn1Object_t policyMappingsObjects[] = {
+ { 0, "policyMappings", ASN1_SEQUENCE, ASN1_LOOP }, /* 0 */
+ { 1, "policyMapping", ASN1_SEQUENCE, ASN1_NONE }, /* 1 */
+ { 2, "issuerPolicy", ASN1_OID, ASN1_BODY }, /* 2 */
+ { 2, "subjectPolicy", ASN1_OID, ASN1_BODY }, /* 3 */
+ { 0, "end loop", ASN1_EOC, ASN1_END }, /* 4 */
+ { 0, "exit", ASN1_EOC, ASN1_EXIT }
+};
+#define POLICY_MAPPING 1
+#define POLICY_MAPPING_ISSUER 2
+#define POLICY_MAPPING_SUBJECT 3
+
+/**
+ * Parse policyMappings
+ */
+static void parse_policyMappings(chunk_t blob, int level0,
+ private_x509_cert_t *this)
+{
+ x509_policy_mapping_t *map = NULL;
+ asn1_parser_t *parser;
+ chunk_t object;
+ int objectID;
+
+ parser = asn1_parser_create(policyMappingsObjects, blob);
+ parser->set_top_level(parser, level0);
+
+ while (parser->iterate(parser, &objectID, &object))
+ {
+ switch (objectID)
+ {
+ case POLICY_MAPPING:
+ INIT(map);
+ this->policy_mappings->insert_last(this->policy_mappings, map);
+ break;
+ case POLICY_MAPPING_ISSUER:
+ if (map && !map->issuer.len)
+ {
+ map->issuer = chunk_clone(object);
+ }
+ break;
+ case POLICY_MAPPING_SUBJECT:
+ if (map && !map->subject.len)
+ {
+ map->subject = chunk_clone(object);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ parser->destroy(parser);
+}
+
+/**
+ * ASN.1 definition of a policyConstraints extension
+ */
+static const asn1Object_t policyConstraintsObjects[] = {
+ { 0, "policyConstraints", ASN1_SEQUENCE, ASN1_NONE }, /* 0 */
+ { 1, "requireExplicitPolicy", ASN1_CONTEXT_C_0, ASN1_OPT|ASN1_NONE }, /* 1 */
+ { 2, "SkipCerts", ASN1_INTEGER, ASN1_BODY }, /* 2 */
+ { 1, "end opt", ASN1_EOC, ASN1_END }, /* 3 */
+ { 1, "inhibitPolicyMapping", ASN1_CONTEXT_C_1, ASN1_OPT|ASN1_NONE }, /* 4 */
+ { 2, "SkipCerts", ASN1_INTEGER, ASN1_BODY }, /* 5 */
+ { 1, "end opt", ASN1_EOC, ASN1_END }, /* 6 */
+ { 0, "exit", ASN1_EOC, ASN1_EXIT }
+};
+#define POLICY_CONSTRAINT_EXPLICIT 2
+#define POLICY_CONSTRAINT_INHIBIT 5
+
+/**
+ * Parse policyConstraints
+ */
+static void parse_policyConstraints(chunk_t blob, int level0,
+ private_x509_cert_t *this)
+{
+ asn1_parser_t *parser;
+ chunk_t object;
+ int objectID;
+
+ parser = asn1_parser_create(policyConstraintsObjects, blob);
+ parser->set_top_level(parser, level0);
+
+ while (parser->iterate(parser, &objectID, &object))
+ {
+ switch (objectID)
+ {
+ case POLICY_CONSTRAINT_EXPLICIT:
+ this->require_explicit = parse_constraint(object);
+ break;
+ case POLICY_CONSTRAINT_INHIBIT:
+ this->inhibit_mapping = parse_constraint(object);
+ break;
+ default:
+ break;
}
}
parser->destroy(parser);
- list->destroy(list);
}
/**
@@ -888,11 +1293,6 @@ static const asn1Object_t certObjects[] = {
#define X509_OBJ_SIGNATURE 25
/**
- * forward declaration
- */
-static bool issued_by(private_x509_cert_t *this, certificate_t *issuer);
-
-/**
* Parses an X.509v3 certificate
*/
static bool parse_certificate(private_x509_cert_t *this)
@@ -992,7 +1392,8 @@ static bool parse_certificate(private_x509_cert_t *this)
parse_basicConstraints(object, level, this);
break;
case OID_CRL_DISTRIBUTION_POINTS:
- parse_crlDistributionPoints(object, level, this);
+ x509_parse_crlDistributionPoints(object, level,
+ this->crl_uris);
break;
case OID_AUTHORITY_KEY_ID:
this->authKeyIdentifier = x509_parse_authorityKeyIdentifier(object,
@@ -1002,7 +1403,7 @@ static bool parse_certificate(private_x509_cert_t *this)
parse_authorityInfoAccess(object, level, this);
break;
case OID_KEY_USAGE:
- /* TODO parse the flags */
+ parse_keyUsage(object, this);
break;
case OID_EXTENDED_KEY_USAGE:
parse_extendedKeyUsage(object, level, this);
@@ -1010,6 +1411,26 @@ static bool parse_certificate(private_x509_cert_t *this)
case OID_IP_ADDR_BLOCKS:
parse_ipAddrBlocks(object, level, this);
break;
+ case OID_NAME_CONSTRAINTS:
+ parse_nameConstraints(object, level, this);
+ break;
+ case OID_CERTIFICATE_POLICIES:
+ parse_certificatePolicies(object, level, this);
+ break;
+ case OID_POLICY_MAPPINGS:
+ parse_policyMappings(object, level, this);
+ break;
+ case OID_POLICY_CONSTRAINTS:
+ parse_policyConstraints(object, level, this);
+ break;
+ case OID_INHIBIT_ANY_POLICY:
+ if (!asn1_parse_simple_object(&object, ASN1_INTEGER,
+ level, "inhibitAnyPolicy"))
+ {
+ goto end;
+ }
+ this->inhibit_any = parse_constraint(object);
+ break;
case OID_NS_REVOCATION_URL:
case OID_NS_CA_REVOCATION_URL:
case OID_NS_CA_POLICY_URL:
@@ -1022,9 +1443,9 @@ static bool parse_certificate(private_x509_cert_t *this)
break;
default:
if (critical && lib->settings->get_bool(lib->settings,
- "libstrongswan.plugins.x509.enforce_critical", FALSE))
+ "libstrongswan.x509.enforce_critical", TRUE))
{
- DBG1(DBG_LIB, "critical %s extension not supported",
+ DBG1(DBG_LIB, "critical '%s' extension not supported",
(extn_oid == OID_UNKNOWN) ? "unknown" :
(char*)oid_names[extn_oid].name);
goto end;
@@ -1057,7 +1478,9 @@ end:
hasher_t *hasher;
/* check if the certificate is self-signed */
- if (issued_by(this, &this->public.interface.interface))
+ if (this->public.interface.interface.issued_by(
+ &this->public.interface.interface,
+ &this->public.interface.interface))
{
this->flags |= X509_SELF_SIGNED;
}
@@ -1074,34 +1497,26 @@ end:
return success;
}
-/**
- * Implementation of certificate_t.get_type
- */
-static certificate_type_t get_type(private_x509_cert_t *this)
+METHOD(certificate_t, get_type, certificate_type_t,
+ private_x509_cert_t *this)
{
return CERT_X509;
}
-/**
- * Implementation of certificate_t.get_subject
- */
-static identification_t* get_subject(private_x509_cert_t *this)
+METHOD(certificate_t, get_subject, identification_t*,
+ private_x509_cert_t *this)
{
return this->subject;
}
-/**
- * Implementation of certificate_t.get_issuer
- */
-static identification_t* get_issuer(private_x509_cert_t *this)
+METHOD(certificate_t, get_issuer, identification_t*,
+ private_x509_cert_t *this)
{
return this->issuer;
}
-/**
- * Implementation of certificate_t.has_subject.
- */
-static id_match_t has_subject(private_x509_cert_t *this, identification_t *subject)
+METHOD(certificate_t, has_subject, id_match_t,
+ private_x509_cert_t *this, identification_t *subject)
{
identification_t *current;
enumerator_t *enumerator;
@@ -1142,19 +1557,15 @@ static id_match_t has_subject(private_x509_cert_t *this, identification_t *subje
return best;
}
-/**
- * Implementation of certificate_t.has_issuer.
- */
-static id_match_t has_issuer(private_x509_cert_t *this, identification_t *issuer)
+METHOD(certificate_t, has_issuer, id_match_t,
+ private_x509_cert_t *this, identification_t *issuer)
{
/* issuerAltNames currently not supported */
return this->issuer->matches(this->issuer, issuer);
}
-/**
- * Implementation of certificate_t.issued_by.
- */
-static bool issued_by(private_x509_cert_t *this, certificate_t *issuer)
+METHOD(certificate_t, issued_by, bool,
+ private_x509_cert_t *this, certificate_t *issuer)
{
public_key_t *key;
signature_scheme_t scheme;
@@ -1201,37 +1612,23 @@ static bool issued_by(private_x509_cert_t *this, certificate_t *issuer)
return valid;
}
-/**
- * Implementation of certificate_t.get_public_key
- */
-static public_key_t* get_public_key(private_x509_cert_t *this)
+METHOD(certificate_t, get_public_key, public_key_t*,
+ private_x509_cert_t *this)
{
this->public_key->get_ref(this->public_key);
return this->public_key;
}
-/**
- * Implementation of certificate_t.get_ref
- */
-static private_x509_cert_t* get_ref(private_x509_cert_t *this)
+METHOD(certificate_t, get_ref, certificate_t*,
+ private_x509_cert_t *this)
{
ref_get(&this->ref);
- return this;
+ return &this->public.interface.interface;
}
-/**
- * Implementation of x509_cert_t.get_flags.
- */
-static x509_flag_t get_flags(private_x509_cert_t *this)
-{
- return this->flags;
-}
-
-/**
- * Implementation of x509_cert_t.get_validity.
- */
-static bool get_validity(private_x509_cert_t *this, time_t *when,
- time_t *not_before, time_t *not_after)
+METHOD(certificate_t, get_validity, bool,
+ private_x509_cert_t *this, time_t *when, time_t *not_before,
+ time_t *not_after)
{
time_t t = when ? *when : time(NULL);
@@ -1246,11 +1643,8 @@ static bool get_validity(private_x509_cert_t *this, time_t *when,
return (t >= this->notBefore && t <= this->notAfter);
}
-/**
- * Implementation of certificate_t.get_encoding.
- */
-static bool get_encoding(private_x509_cert_t *this, cred_encoding_type_t type,
- chunk_t *encoding)
+METHOD(certificate_t, get_encoding, bool,
+ private_x509_cert_t *this, cred_encoding_type_t type, chunk_t *encoding)
{
if (type == CERT_ASN1_DER)
{
@@ -1261,10 +1655,8 @@ static bool get_encoding(private_x509_cert_t *this, cred_encoding_type_t type,
CRED_PART_X509_ASN1_DER, this->encoding, CRED_PART_END);
}
-/**
- * Implementation of certificate_t.equals.
- */
-static bool equals(private_x509_cert_t *this, certificate_t *other)
+METHOD(certificate_t, equals, bool,
+ private_x509_cert_t *this, certificate_t *other)
{
chunk_t encoding;
bool equal;
@@ -1290,18 +1682,20 @@ static bool equals(private_x509_cert_t *this, certificate_t *other)
return equal;
}
-/**
- * Implementation of x509_t.get_serial.
- */
-static chunk_t get_serial(private_x509_cert_t *this)
+METHOD(x509_t, get_flags, x509_flag_t,
+ private_x509_cert_t *this)
+{
+ return this->flags;
+}
+
+METHOD(x509_t, get_serial, chunk_t,
+ private_x509_cert_t *this)
{
return this->serialNumber;
}
-/**
- * Implementation of x509_t.get_subjectKeyIdentifier.
- */
-static chunk_t get_subjectKeyIdentifier(private_x509_cert_t *this)
+METHOD(x509_t, get_subjectKeyIdentifier, chunk_t,
+ private_x509_cert_t *this)
{
if (this->subjectKeyIdentifier.ptr)
{
@@ -1323,66 +1717,95 @@ static chunk_t get_subjectKeyIdentifier(private_x509_cert_t *this)
}
}
-/**
- * Implementation of x509_t.get_authKeyIdentifier.
- */
-static chunk_t get_authKeyIdentifier(private_x509_cert_t *this)
+METHOD(x509_t, get_authKeyIdentifier, chunk_t,
+ private_x509_cert_t *this)
{
return this->authKeyIdentifier;
}
-/**
- * Implementation of x509_t.get_pathLenConstraint.
- */
-static int get_pathLenConstraint(private_x509_cert_t *this)
+METHOD(x509_t, get_constraint, u_int,
+ private_x509_cert_t *this, x509_constraint_t type)
{
- return this->pathLenConstraint;
+ switch (type)
+ {
+ case X509_PATH_LEN:
+ return this->pathLenConstraint;
+ case X509_REQUIRE_EXPLICIT_POLICY:
+ return this->require_explicit;
+ case X509_INHIBIT_POLICY_MAPPING:
+ return this->inhibit_mapping;
+ case X509_INHIBIT_ANY_POLICY:
+ return this->inhibit_any;
+ default:
+ return X509_NO_CONSTRAINT;
+ }
}
-/**
- * Implementation of x509_cert_t.create_subjectAltName_enumerator.
- */
-static enumerator_t* create_subjectAltName_enumerator(private_x509_cert_t *this)
+METHOD(x509_t, create_subjectAltName_enumerator, enumerator_t*,
+ private_x509_cert_t *this)
{
return this->subjectAltNames->create_enumerator(this->subjectAltNames);
}
-/**
- * Implementation of x509_cert_t.create_ocsp_uri_enumerator.
- */
-static enumerator_t* create_ocsp_uri_enumerator(private_x509_cert_t *this)
+METHOD(x509_t, create_ocsp_uri_enumerator, enumerator_t*,
+ private_x509_cert_t *this)
{
return this->ocsp_uris->create_enumerator(this->ocsp_uris);
}
-/**
- * Implementation of x509_cert_t.create_crl_uri_enumerator.
- */
-static enumerator_t* create_crl_uri_enumerator(private_x509_cert_t *this)
+METHOD(x509_t, create_crl_uri_enumerator, enumerator_t*,
+ private_x509_cert_t *this)
{
return this->crl_uris->create_enumerator(this->crl_uris);
}
-/**
- * Implementation of x509_cert_t.create_ipAddrBlock_enumerator.
- */
-static enumerator_t* create_ipAddrBlock_enumerator(private_x509_cert_t *this)
+METHOD(x509_t, create_ipAddrBlock_enumerator, enumerator_t*,
+ private_x509_cert_t *this)
{
return this->ipAddrBlocks->create_enumerator(this->ipAddrBlocks);
}
-/**
- * Implementation of certificate_t.destroy.
- */
-static void destroy(private_x509_cert_t *this)
+METHOD(x509_t, create_name_constraint_enumerator, enumerator_t*,
+ private_x509_cert_t *this, bool perm)
+{
+ if (perm)
+ {
+ return this->permitted_names->create_enumerator(this->permitted_names);
+ }
+ return this->excluded_names->create_enumerator(this->excluded_names);
+}
+
+METHOD(x509_t, create_cert_policy_enumerator, enumerator_t*,
+ private_x509_cert_t *this)
+{
+ return this->cert_policies->create_enumerator(this->cert_policies);
+}
+
+METHOD(x509_t, create_policy_mapping_enumerator, enumerator_t*,
+ private_x509_cert_t *this)
+{
+ return this->policy_mappings->create_enumerator(this->policy_mappings);
+}
+
+METHOD(certificate_t, destroy, void,
+ private_x509_cert_t *this)
{
if (ref_put(&this->ref))
{
this->subjectAltNames->destroy_offset(this->subjectAltNames,
offsetof(identification_t, destroy));
- this->crl_uris->destroy_function(this->crl_uris, free);
+ this->crl_uris->destroy_function(this->crl_uris, (void*)crl_uri_destroy);
this->ocsp_uris->destroy_function(this->ocsp_uris, free);
- this->ipAddrBlocks->destroy_offset(this->ipAddrBlocks, offsetof(traffic_selector_t, destroy));
+ this->ipAddrBlocks->destroy_offset(this->ipAddrBlocks,
+ offsetof(traffic_selector_t, destroy));
+ this->permitted_names->destroy_offset(this->permitted_names,
+ offsetof(identification_t, destroy));
+ this->excluded_names->destroy_offset(this->excluded_names,
+ offsetof(identification_t, destroy));
+ this->cert_policies->destroy_function(this->cert_policies,
+ (void*)cert_policy_destroy);
+ this->policy_mappings->destroy_function(this->policy_mappings,
+ (void*)policy_mapping_destroy);
DESTROY_IF(this->issuer);
DESTROY_IF(this->subject);
DESTROY_IF(this->public_key);
@@ -1404,63 +1827,93 @@ static void destroy(private_x509_cert_t *this)
*/
static private_x509_cert_t* create_empty(void)
{
- private_x509_cert_t *this = malloc_thing(private_x509_cert_t);
-
- this->public.interface.interface.get_type = (certificate_type_t (*) (certificate_t*))get_type;
- this->public.interface.interface.get_subject = (identification_t* (*) (certificate_t*))get_subject;
- this->public.interface.interface.get_issuer = (identification_t* (*) (certificate_t*))get_issuer;
- this->public.interface.interface.has_subject = (id_match_t (*) (certificate_t*, identification_t*))has_subject;
- this->public.interface.interface.has_issuer = (id_match_t (*) (certificate_t*, identification_t*))has_issuer;
- this->public.interface.interface.issued_by = (bool (*) (certificate_t*, certificate_t*))issued_by;
- this->public.interface.interface.get_public_key = (public_key_t* (*) (certificate_t*))get_public_key;
- this->public.interface.interface.get_validity = (bool (*) (certificate_t*, time_t*, time_t*, time_t*))get_validity;
- this->public.interface.interface.get_encoding = (bool (*) (certificate_t*,cred_encoding_type_t,chunk_t*))get_encoding;
- this->public.interface.interface.equals = (bool (*)(certificate_t*, certificate_t*))equals;
- this->public.interface.interface.get_ref = (certificate_t* (*)(certificate_t*))get_ref;
- this->public.interface.interface.destroy = (void (*)(certificate_t*))destroy;
- this->public.interface.get_flags = (x509_flag_t (*)(x509_t*))get_flags;
- this->public.interface.get_serial = (chunk_t (*)(x509_t*))get_serial;
- this->public.interface.get_subjectKeyIdentifier = (chunk_t (*)(x509_t*))get_subjectKeyIdentifier;
- this->public.interface.get_authKeyIdentifier = (chunk_t (*)(x509_t*))get_authKeyIdentifier;
- this->public.interface.get_pathLenConstraint = (int (*)(x509_t*))get_pathLenConstraint;
- this->public.interface.create_subjectAltName_enumerator = (enumerator_t* (*)(x509_t*))create_subjectAltName_enumerator;
- this->public.interface.create_crl_uri_enumerator = (enumerator_t* (*)(x509_t*))create_crl_uri_enumerator;
- this->public.interface.create_ocsp_uri_enumerator = (enumerator_t* (*)(x509_t*))create_ocsp_uri_enumerator;
- this->public.interface.create_ipAddrBlock_enumerator = (enumerator_t* (*)(x509_t*))create_ipAddrBlock_enumerator;
-
- this->encoding = chunk_empty;
- this->encoding_hash = chunk_empty;
- this->tbsCertificate = chunk_empty;
- this->version = 1;
- this->serialNumber = chunk_empty;
- this->notBefore = 0;
- this->notAfter = 0;
- this->public_key = NULL;
- this->subject = NULL;
- this->issuer = NULL;
- this->subjectAltNames = linked_list_create();
- this->crl_uris = linked_list_create();
- this->ocsp_uris = linked_list_create();
- this->ipAddrBlocks = linked_list_create();
- this->subjectKeyIdentifier = chunk_empty;
- this->authKeyIdentifier = chunk_empty;
- this->authKeySerialNumber = chunk_empty;
- this->pathLenConstraint = X509_NO_PATH_LEN_CONSTRAINT;
- this->algorithm = 0;
- this->signature = chunk_empty;
- this->flags = 0;
- this->ref = 1;
- this->parsed = FALSE;
-
+ private_x509_cert_t *this;
+
+ INIT(this,
+ .public = {
+ .interface = {
+ .interface = {
+ .get_type = _get_type,
+ .get_subject = _get_subject,
+ .get_issuer = _get_issuer,
+ .has_subject = _has_subject,
+ .has_issuer = _has_issuer,
+ .issued_by = _issued_by,
+ .get_public_key = _get_public_key,
+ .get_validity = _get_validity,
+ .get_encoding = _get_encoding,
+ .equals = _equals,
+ .get_ref = _get_ref,
+ .destroy = _destroy,
+ },
+ .get_flags = _get_flags,
+ .get_serial = _get_serial,
+ .get_subjectKeyIdentifier = _get_subjectKeyIdentifier,
+ .get_authKeyIdentifier = _get_authKeyIdentifier,
+ .get_constraint = _get_constraint,
+ .create_subjectAltName_enumerator = _create_subjectAltName_enumerator,
+ .create_crl_uri_enumerator = _create_crl_uri_enumerator,
+ .create_ocsp_uri_enumerator = _create_ocsp_uri_enumerator,
+ .create_ipAddrBlock_enumerator = _create_ipAddrBlock_enumerator,
+ .create_name_constraint_enumerator = _create_name_constraint_enumerator,
+ .create_cert_policy_enumerator = _create_cert_policy_enumerator,
+ .create_policy_mapping_enumerator = _create_policy_mapping_enumerator,
+ },
+ },
+ .version = 1,
+ .subjectAltNames = linked_list_create(),
+ .crl_uris = linked_list_create(),
+ .ocsp_uris = linked_list_create(),
+ .ipAddrBlocks = linked_list_create(),
+ .permitted_names = linked_list_create(),
+ .excluded_names = linked_list_create(),
+ .cert_policies = linked_list_create(),
+ .policy_mappings = linked_list_create(),
+ .pathLenConstraint = X509_NO_CONSTRAINT,
+ .require_explicit = X509_NO_CONSTRAINT,
+ .inhibit_mapping = X509_NO_CONSTRAINT,
+ .inhibit_any = X509_NO_CONSTRAINT,
+ .ref = 1,
+ );
return this;
}
/**
+ * Build a generalName from an id
+ */
+chunk_t build_generalName(identification_t *id)
+{
+ int context;
+
+ switch (id->get_type(id))
+ {
+ case ID_RFC822_ADDR:
+ context = ASN1_CONTEXT_S_1;
+ break;
+ case ID_FQDN:
+ context = ASN1_CONTEXT_S_2;
+ break;
+ case ID_DER_ASN1_DN:
+ context = ASN1_CONTEXT_C_4;
+ break;
+ case ID_IPV4_ADDR:
+ case ID_IPV6_ADDR:
+ context = ASN1_CONTEXT_S_7;
+ break;
+ default:
+ DBG1(DBG_LIB, "encoding %N as generalName not supported",
+ id_type_names, id->get_type(id));
+ return chunk_empty;
+ }
+ return asn1_wrap(context, "c", id->get_encoding(id));
+}
+
+/**
* Encode a linked list of subjectAltNames
*/
chunk_t x509_build_subjectAltNames(linked_list_t *list)
{
- chunk_t subjectAltNames = chunk_empty;
+ chunk_t subjectAltNames = chunk_empty, name;
enumerator_t *enumerator;
identification_t *id;
@@ -1472,29 +1925,7 @@ chunk_t x509_build_subjectAltNames(linked_list_t *list)
enumerator = list->create_enumerator(list);
while (enumerator->enumerate(enumerator, &id))
{
- int context;
- chunk_t name;
-
- switch (id->get_type(id))
- {
- case ID_RFC822_ADDR:
- context = ASN1_CONTEXT_S_1;
- break;
- case ID_FQDN:
- context = ASN1_CONTEXT_S_2;
- break;
- case ID_IPV4_ADDR:
- case ID_IPV6_ADDR:
- context = ASN1_CONTEXT_S_7;
- break;
- default:
- DBG1(DBG_LIB, "encoding %N as subjectAltName not supported",
- id_type_names, id->get_type(id));
- enumerator->destroy(enumerator);
- free(subjectAltNames.ptr);
- return chunk_empty;
- }
- name = asn1_wrap(context, "c", id->get_encoding(id));
+ name = build_generalName(id);
subjectAltNames = chunk_cat("mm", subjectAltNames, name);
}
enumerator->destroy(enumerator);
@@ -1508,6 +1939,47 @@ chunk_t x509_build_subjectAltNames(linked_list_t *list)
}
/**
+ * Encode CRL distribution points extension from a x509_cdp_t list
+ */
+chunk_t x509_build_crlDistributionPoints(linked_list_t *list, int extn)
+{
+ chunk_t crlDistributionPoints = chunk_empty;
+ enumerator_t *enumerator;
+ x509_cdp_t *cdp;
+
+ if (list->get_count(list) == 0)
+ {
+ return chunk_empty;
+ }
+
+ enumerator = list->create_enumerator(list);
+ while (enumerator->enumerate(enumerator, &cdp))
+ {
+ chunk_t distributionPoint, crlIssuer = chunk_empty;
+
+ if (cdp->issuer)
+ {
+ crlIssuer = asn1_wrap(ASN1_CONTEXT_C_2, "m",
+ build_generalName(cdp->issuer));
+ }
+ distributionPoint = asn1_wrap(ASN1_SEQUENCE, "mm",
+ asn1_wrap(ASN1_CONTEXT_C_0, "m",
+ asn1_wrap(ASN1_CONTEXT_C_0, "m",
+ asn1_wrap(ASN1_CONTEXT_S_6, "c",
+ chunk_create(cdp->uri, strlen(cdp->uri))))),
+ crlIssuer);
+ crlDistributionPoints = chunk_cat("mm", crlDistributionPoints,
+ distributionPoint);
+ }
+ enumerator->destroy(enumerator);
+
+ return asn1_wrap(ASN1_SEQUENCE, "mm",
+ asn1_build_known_oid(extn),
+ asn1_wrap(ASN1_OCTET_STRING, "m",
+ asn1_wrap(ASN1_SEQUENCE, "m", crlDistributionPoints)));
+}
+
+/**
* Generate and sign a new certificate
*/
static bool generate(private_x509_cert_t *cert, certificate_t *sign_cert,
@@ -1515,12 +1987,13 @@ static bool generate(private_x509_cert_t *cert, certificate_t *sign_cert,
{
chunk_t extensions = chunk_empty, extendedKeyUsage = chunk_empty;
chunk_t serverAuth = chunk_empty, clientAuth = chunk_empty;
- chunk_t ocspSigning = chunk_empty;
- chunk_t basicConstraints = chunk_empty;
- chunk_t keyUsage = chunk_empty;
- chunk_t subjectAltNames = chunk_empty;
+ chunk_t ocspSigning = chunk_empty, certPolicies = chunk_empty;
+ chunk_t basicConstraints = chunk_empty, nameConstraints = chunk_empty;
+ chunk_t keyUsage = chunk_empty, keyUsageBits = chunk_empty;
+ chunk_t subjectAltNames = chunk_empty, policyMappings = chunk_empty;
chunk_t subjectKeyIdentifier = chunk_empty, authKeyIdentifier = chunk_empty;
chunk_t crlDistributionPoints = chunk_empty, authorityInfoAccess = chunk_empty;
+ chunk_t policyConstraints = chunk_empty, inhibitAnyPolicy = chunk_empty;
identification_t *issuer, *subject;
chunk_t key_info;
signature_scheme_t scheme;
@@ -1574,29 +2047,8 @@ static bool generate(private_x509_cert_t *cert, certificate_t *sign_cert,
/* encode subjectAltNames */
subjectAltNames = x509_build_subjectAltNames(cert->subjectAltNames);
- /* encode CRL distribution points extension */
- enumerator = cert->crl_uris->create_enumerator(cert->crl_uris);
- while (enumerator->enumerate(enumerator, &uri))
- {
- chunk_t distributionPoint;
-
- distributionPoint = asn1_wrap(ASN1_SEQUENCE, "m",
- asn1_wrap(ASN1_CONTEXT_C_0, "m",
- asn1_wrap(ASN1_CONTEXT_C_0, "m",
- asn1_wrap(ASN1_CONTEXT_S_6, "c",
- chunk_create(uri, strlen(uri))))));
-
- crlDistributionPoints = chunk_cat("mm", crlDistributionPoints,
- distributionPoint);
- }
- enumerator->destroy(enumerator);
- if (crlDistributionPoints.ptr)
- {
- crlDistributionPoints = asn1_wrap(ASN1_SEQUENCE, "mm",
- asn1_build_known_oid(OID_CRL_DISTRIBUTION_POINTS),
- asn1_wrap(ASN1_OCTET_STRING, "m",
- asn1_wrap(ASN1_SEQUENCE, "m", crlDistributionPoints)));
- }
+ crlDistributionPoints = x509_build_crlDistributionPoints(cert->crl_uris,
+ OID_CRL_DISTRIBUTION_POINTS);
/* encode OCSP URIs in authorityInfoAccess extension */
enumerator = cert->ocsp_uris->create_enumerator(cert->ocsp_uris);
@@ -1625,11 +2077,10 @@ static bool generate(private_x509_cert_t *cert, certificate_t *sign_cert,
{
chunk_t pathLenConstraint = chunk_empty;
- if (cert->pathLenConstraint != X509_NO_PATH_LEN_CONSTRAINT)
+ if (cert->pathLenConstraint != X509_NO_CONSTRAINT)
{
- char pathlen = (char)cert->pathLenConstraint;
-
- pathLenConstraint = asn1_integer("c", chunk_from_thing(pathlen));
+ pathLenConstraint = asn1_integer("c",
+ chunk_from_thing(cert->pathLenConstraint));
}
basicConstraints = asn1_wrap(ASN1_SEQUENCE, "mmm",
asn1_build_known_oid(OID_BASIC_CONSTRAINTS),
@@ -1640,13 +2091,20 @@ static bool generate(private_x509_cert_t *cert, certificate_t *sign_cert,
asn1_wrap(ASN1_BOOLEAN, "c",
chunk_from_chars(0xFF)),
pathLenConstraint)));
+ /* set CertificateSign and implicitly CRLsign */
+ keyUsageBits = chunk_from_chars(0x01, 0x06);
+ }
+ else if (cert->flags & X509_CRL_SIGN)
+ {
+ keyUsageBits = chunk_from_chars(0x01, 0x02);
+ }
+ if (keyUsageBits.len)
+ {
keyUsage = asn1_wrap(ASN1_SEQUENCE, "mmm",
- asn1_build_known_oid(OID_KEY_USAGE),
- asn1_wrap(ASN1_BOOLEAN, "c",
- chunk_from_chars(0xFF)),
- asn1_wrap(ASN1_OCTET_STRING, "m",
- asn1_wrap(ASN1_BIT_STRING, "c",
- chunk_from_chars(0x01, 0x06))));
+ asn1_build_known_oid(OID_KEY_USAGE),
+ asn1_wrap(ASN1_BOOLEAN, "c", chunk_from_chars(0xFF)),
+ asn1_wrap(ASN1_OCTET_STRING, "m",
+ asn1_wrap(ASN1_BIT_STRING, "c", keyUsageBits)));
}
/* add serverAuth extendedKeyUsage flag */
@@ -1675,7 +2133,7 @@ static bool generate(private_x509_cert_t *cert, certificate_t *sign_cert,
}
/* add subjectKeyIdentifier to CA and OCSP signer certificates */
- if (cert->flags & (X509_CA | X509_OCSP_SIGNER))
+ if (cert->flags & (X509_CA | X509_OCSP_SIGNER | X509_CRL_SIGN))
{
chunk_t keyid;
@@ -1703,15 +2161,153 @@ static bool generate(private_x509_cert_t *cert, certificate_t *sign_cert,
asn1_wrap(ASN1_CONTEXT_S_0, "c", keyid))));
}
}
+
+ if (cert->permitted_names->get_count(cert->permitted_names) ||
+ cert->excluded_names->get_count(cert->excluded_names))
+ {
+ chunk_t permitted = chunk_empty, excluded = chunk_empty, subtree;
+ identification_t *id;
+
+ enumerator = create_name_constraint_enumerator(cert, TRUE);
+ while (enumerator->enumerate(enumerator, &id))
+ {
+ subtree = asn1_wrap(ASN1_SEQUENCE, "m", build_generalName(id));
+ permitted = chunk_cat("mm", permitted, subtree);
+ }
+ enumerator->destroy(enumerator);
+ if (permitted.ptr)
+ {
+ permitted = asn1_wrap(ASN1_CONTEXT_C_0, "m", permitted);
+ }
+
+ enumerator = create_name_constraint_enumerator(cert, FALSE);
+ while (enumerator->enumerate(enumerator, &id))
+ {
+ subtree = asn1_wrap(ASN1_SEQUENCE, "m", build_generalName(id));
+ excluded = chunk_cat("mm", excluded, subtree);
+ }
+ enumerator->destroy(enumerator);
+ if (excluded.ptr)
+ {
+ excluded = asn1_wrap(ASN1_CONTEXT_C_1, "m", excluded);
+ }
+
+ nameConstraints = asn1_wrap(ASN1_SEQUENCE, "mm",
+ asn1_build_known_oid(OID_NAME_CONSTRAINTS),
+ asn1_wrap(ASN1_OCTET_STRING, "m",
+ asn1_wrap(ASN1_SEQUENCE, "mm",
+ permitted, excluded)));
+ }
+
+ if (cert->cert_policies->get_count(cert->cert_policies))
+ {
+ x509_cert_policy_t *policy;
+
+ enumerator = create_cert_policy_enumerator(cert);
+ while (enumerator->enumerate(enumerator, &policy))
+ {
+ chunk_t chunk = chunk_empty, cps = chunk_empty, notice = chunk_empty;
+
+ if (policy->cps_uri)
+ {
+ cps = asn1_wrap(ASN1_SEQUENCE, "mm",
+ asn1_build_known_oid(OID_POLICY_QUALIFIER_CPS),
+ asn1_wrap(ASN1_IA5STRING, "c",
+ chunk_create(policy->cps_uri,
+ strlen(policy->cps_uri))));
+ }
+ if (policy->unotice_text)
+ {
+ notice = asn1_wrap(ASN1_SEQUENCE, "mm",
+ asn1_build_known_oid(OID_POLICY_QUALIFIER_UNOTICE),
+ asn1_wrap(ASN1_SEQUENCE, "m",
+ asn1_wrap(ASN1_VISIBLESTRING, "c",
+ chunk_create(policy->unotice_text,
+ strlen(policy->unotice_text)))));
+ }
+ if (cps.len || notice.len)
+ {
+ chunk = asn1_wrap(ASN1_SEQUENCE, "mm", cps, notice);
+ }
+ chunk = asn1_wrap(ASN1_SEQUENCE, "mm",
+ asn1_wrap(ASN1_OID, "c", policy->oid), chunk);
+ certPolicies = chunk_cat("mm", certPolicies, chunk);
+ }
+ enumerator->destroy(enumerator);
+
+ certPolicies = asn1_wrap(ASN1_SEQUENCE, "mm",
+ asn1_build_known_oid(OID_CERTIFICATE_POLICIES),
+ asn1_wrap(ASN1_OCTET_STRING, "m",
+ asn1_wrap(ASN1_SEQUENCE, "m", certPolicies)));
+ }
+
+ if (cert->policy_mappings->get_count(cert->policy_mappings))
+ {
+ x509_policy_mapping_t *mapping;
+
+ enumerator = create_policy_mapping_enumerator(cert);
+ while (enumerator->enumerate(enumerator, &mapping))
+ {
+ chunk_t chunk;
+
+ chunk = asn1_wrap(ASN1_SEQUENCE, "mm",
+ asn1_wrap(ASN1_OID, "c", mapping->issuer),
+ asn1_wrap(ASN1_OID, "c", mapping->subject));
+ policyMappings = chunk_cat("mm", policyMappings, chunk);
+ }
+ enumerator->destroy(enumerator);
+
+ policyMappings = asn1_wrap(ASN1_SEQUENCE, "mm",
+ asn1_build_known_oid(OID_POLICY_MAPPINGS),
+ asn1_wrap(ASN1_OCTET_STRING, "m",
+ asn1_wrap(ASN1_SEQUENCE, "m", policyMappings)));
+ }
+
+ if (cert->inhibit_mapping != X509_NO_CONSTRAINT ||
+ cert->require_explicit != X509_NO_CONSTRAINT)
+ {
+ chunk_t inhibit = chunk_empty, explicit = chunk_empty;
+
+ if (cert->require_explicit != X509_NO_CONSTRAINT)
+ {
+ explicit = asn1_wrap(ASN1_CONTEXT_C_0, "m",
+ asn1_integer("c",
+ chunk_from_thing(cert->require_explicit)));
+ }
+ if (cert->inhibit_mapping != X509_NO_CONSTRAINT)
+ {
+ inhibit = asn1_wrap(ASN1_CONTEXT_C_1, "m",
+ asn1_integer("c",
+ chunk_from_thing(cert->inhibit_mapping)));
+ }
+ policyConstraints = asn1_wrap(ASN1_SEQUENCE, "mmm",
+ asn1_build_known_oid(OID_POLICY_CONSTRAINTS),
+ asn1_wrap(ASN1_BOOLEAN, "c", chunk_from_chars(0xFF)),
+ asn1_wrap(ASN1_OCTET_STRING, "m",
+ asn1_wrap(ASN1_SEQUENCE, "mm",
+ explicit, inhibit)));
+ }
+
+ if (cert->inhibit_any != X509_NO_CONSTRAINT)
+ {
+ inhibitAnyPolicy = asn1_wrap(ASN1_SEQUENCE, "mmm",
+ asn1_build_known_oid(OID_INHIBIT_ANY_POLICY),
+ asn1_wrap(ASN1_BOOLEAN, "c", chunk_from_chars(0xFF)),
+ asn1_wrap(ASN1_OCTET_STRING, "m",
+ asn1_integer("c",
+ chunk_from_thing(cert->inhibit_any))));
+ }
+
if (basicConstraints.ptr || subjectAltNames.ptr || authKeyIdentifier.ptr ||
- crlDistributionPoints.ptr)
+ crlDistributionPoints.ptr || nameConstraints.ptr)
{
extensions = asn1_wrap(ASN1_CONTEXT_C_3, "m",
- asn1_wrap(ASN1_SEQUENCE, "mmmmmmmm",
+ asn1_wrap(ASN1_SEQUENCE, "mmmmmmmmmmmmm",
basicConstraints, keyUsage, subjectKeyIdentifier,
authKeyIdentifier, subjectAltNames,
extendedKeyUsage, crlDistributionPoints,
- authorityInfoAccess));
+ authorityInfoAccess, nameConstraints, certPolicies,
+ policyMappings, policyConstraints, inhibitAnyPolicy));
}
cert->tbsCertificate = asn1_wrap(ASN1_SEQUENCE, "mmmcmcmm",
@@ -1794,6 +2390,7 @@ x509_cert_t *x509_cert_gen(certificate_type_t type, va_list args)
certificate_t *sign_cert = NULL;
private_key_t *sign_key = NULL;
hash_algorithm_t digest_alg = HASH_SHA1;
+ u_int constraint;
cert = create_empty();
while (TRUE)
@@ -1837,13 +2434,17 @@ x509_cert_t *x509_cert_gen(certificate_type_t type, va_list args)
{
enumerator_t *enumerator;
linked_list_t *list;
- char *uri;
+ x509_cdp_t *in, *cdp;
list = va_arg(args, linked_list_t*);
enumerator = list->create_enumerator(list);
- while (enumerator->enumerate(enumerator, &uri))
+ while (enumerator->enumerate(enumerator, &in))
{
- cert->crl_uris->insert_last(cert->crl_uris, strdup(uri));
+ INIT(cdp,
+ .uri = strdup(in->uri),
+ .issuer = in->issuer ? in->issuer->clone(in->issuer) : NULL,
+ );
+ cert->crl_uris->insert_last(cert->crl_uris, cdp);
}
enumerator->destroy(enumerator);
continue;
@@ -1864,11 +2465,96 @@ x509_cert_t *x509_cert_gen(certificate_type_t type, va_list args)
continue;
}
case BUILD_PATHLEN:
- cert->pathLenConstraint = va_arg(args, int);
- if (cert->pathLenConstraint < 0 || cert->pathLenConstraint > 127)
+ constraint = va_arg(args, u_int);
+ cert->pathLenConstraint = (constraint < 128) ?
+ constraint : X509_NO_CONSTRAINT;
+ continue;
+ case BUILD_PERMITTED_NAME_CONSTRAINTS:
+ {
+ enumerator_t *enumerator;
+ linked_list_t *list;
+ identification_t *constraint;
+
+ list = va_arg(args, linked_list_t*);
+ enumerator = list->create_enumerator(list);
+ while (enumerator->enumerate(enumerator, &constraint))
+ {
+ cert->permitted_names->insert_last(cert->permitted_names,
+ constraint->clone(constraint));
+ }
+ enumerator->destroy(enumerator);
+ continue;
+ }
+ case BUILD_EXCLUDED_NAME_CONSTRAINTS:
+ {
+ enumerator_t *enumerator;
+ linked_list_t *list;
+ identification_t *constraint;
+
+ list = va_arg(args, linked_list_t*);
+ enumerator = list->create_enumerator(list);
+ while (enumerator->enumerate(enumerator, &constraint))
+ {
+ cert->excluded_names->insert_last(cert->excluded_names,
+ constraint->clone(constraint));
+ }
+ enumerator->destroy(enumerator);
+ continue;
+ }
+ case BUILD_CERTIFICATE_POLICIES:
+ {
+ enumerator_t *enumerator;
+ linked_list_t *list;
+ x509_cert_policy_t *policy, *in;
+
+ list = va_arg(args, linked_list_t*);
+ enumerator = list->create_enumerator(list);
+ while (enumerator->enumerate(enumerator, &in))
+ {
+ INIT(policy,
+ .oid = chunk_clone(in->oid),
+ .cps_uri = strdupnull(in->cps_uri),
+ .unotice_text = strdupnull(in->unotice_text),
+ );
+ cert->cert_policies->insert_last(cert->cert_policies, policy);
+ }
+ enumerator->destroy(enumerator);
+ continue;
+ }
+ case BUILD_POLICY_MAPPINGS:
+ {
+ enumerator_t *enumerator;
+ linked_list_t *list;
+ x509_policy_mapping_t* mapping, *in;
+
+ list = va_arg(args, linked_list_t*);
+ enumerator = list->create_enumerator(list);
+ while (enumerator->enumerate(enumerator, &in))
{
- cert->pathLenConstraint = X509_NO_PATH_LEN_CONSTRAINT;
+ INIT(mapping,
+ .issuer = chunk_clone(in->issuer),
+ .subject = chunk_clone(in->subject),
+ );
+ cert->policy_mappings->insert_last(cert->policy_mappings,
+ mapping);
}
+ enumerator->destroy(enumerator);
+ continue;
+ }
+ case BUILD_POLICY_REQUIRE_EXPLICIT:
+ constraint = va_arg(args, u_int);
+ cert->require_explicit = (constraint < 128) ?
+ constraint : X509_NO_CONSTRAINT;
+ continue;
+ case BUILD_POLICY_INHIBIT_MAPPING:
+ constraint = va_arg(args, u_int);
+ cert->inhibit_mapping = (constraint < 128) ?
+ constraint : X509_NO_CONSTRAINT;
+ continue;
+ case BUILD_POLICY_INHIBIT_ANY:
+ constraint = va_arg(args, u_int);
+ cert->inhibit_any = (constraint < 128) ?
+ constraint : X509_NO_CONSTRAINT;
continue;
case BUILD_NOT_BEFORE_TIME:
cert->notBefore = va_arg(args, time_t);
diff --git a/src/libstrongswan/plugins/x509/x509_crl.c b/src/libstrongswan/plugins/x509/x509_crl.c
index 4bd0470d3..758505ab5 100644
--- a/src/libstrongswan/plugins/x509/x509_crl.c
+++ b/src/libstrongswan/plugins/x509/x509_crl.c
@@ -100,6 +100,11 @@ struct private_x509_crl_t {
linked_list_t *revoked;
/**
+ * List of Freshest CRL distribution points
+ */
+ linked_list_t *crl_uris;
+
+ /**
* Authority Key Identifier
*/
chunk_t authKeyIdentifier;
@@ -110,6 +115,11 @@ struct private_x509_crl_t {
chunk_t authKeySerialNumber;
/**
+ * Number of BaseCRL, if a delta CRL
+ */
+ chunk_t baseCrlNumber;
+
+ /**
* Signature algorithm
*/
int algorithm;
@@ -133,9 +143,19 @@ struct private_x509_crl_t {
/**
* from x509_cert
*/
-extern chunk_t x509_parse_authorityKeyIdentifier(
- chunk_t blob, int level0,
- chunk_t *authKeySerialNumber);
+extern chunk_t x509_parse_authorityKeyIdentifier(chunk_t blob, int level0,
+ chunk_t *authKeySerialNumber);
+
+/**
+ * from x509_cert
+ */
+extern void x509_parse_crlDistributionPoints(chunk_t blob, int level0,
+ linked_list_t *list);
+
+/**
+ * from x509_cert
+ */
+extern chunk_t x509_build_crlDistributionPoints(linked_list_t *list, int extn);
/**
* ASN.1 definition of an X.509 certificate revocation list
@@ -206,7 +226,7 @@ static bool parse(private_x509_crl_t *this)
int objectID;
int sig_alg = OID_UNKNOWN;
bool success = FALSE;
- bool critical;
+ bool critical = FALSE;
revoked_t *revoked = NULL;
parser = asn1_parser_create(crlObjects, this->encoding);
@@ -258,35 +278,61 @@ static bool parse(private_x509_crl_t *this)
break;
case CRL_OBJ_CRL_ENTRY_EXTN_VALUE:
case CRL_OBJ_EXTN_VALUE:
- {
- int extn_oid = asn1_known_oid(extnID);
+ {
+ int extn_oid = asn1_known_oid(extnID);
- if (revoked && extn_oid == OID_CRL_REASON_CODE)
- {
- if (*object.ptr == ASN1_ENUMERATED &&
- asn1_length(&object) == 1)
+ switch (extn_oid)
+ {
+ case OID_CRL_REASON_CODE:
+ if (revoked)
{
- revoked->reason = *object.ptr;
+ if (object.len && *object.ptr == ASN1_ENUMERATED &&
+ asn1_length(&object) == 1)
+ {
+ revoked->reason = *object.ptr;
+ }
+ DBG2(DBG_LIB, " '%N'", crl_reason_names,
+ revoked->reason);
}
- DBG2(DBG_LIB, " '%N'", crl_reason_names,
- revoked->reason);
- }
- else if (extn_oid == OID_AUTHORITY_KEY_ID)
- {
- this->authKeyIdentifier = x509_parse_authorityKeyIdentifier(object,
- level, &this->authKeySerialNumber);
- }
- else if (extn_oid == OID_CRL_NUMBER)
- {
+ break;
+ case OID_AUTHORITY_KEY_ID:
+ this->authKeyIdentifier =
+ x509_parse_authorityKeyIdentifier(
+ object, level, &this->authKeySerialNumber);
+ break;
+ case OID_CRL_NUMBER:
if (!asn1_parse_simple_object(&object, ASN1_INTEGER,
level, "crlNumber"))
{
goto end;
}
this->crlNumber = object;
- }
+ break;
+ case OID_FRESHEST_CRL:
+ x509_parse_crlDistributionPoints(object, level,
+ this->crl_uris);
+ break;
+ case OID_DELTA_CRL_INDICATOR:
+ if (!asn1_parse_simple_object(&object, ASN1_INTEGER,
+ level, "deltaCrlIndicator"))
+ {
+ goto end;
+ }
+ this->baseCrlNumber = object;
+ break;
+ default:
+ if (critical && lib->settings->get_bool(lib->settings,
+ "libstrongswan.x509.enforce_critical", TRUE))
+ {
+ DBG1(DBG_LIB, "critical '%s' extension not supported",
+ (extn_oid == OID_UNKNOWN) ? "unknown" :
+ (char*)oid_names[extn_oid].name);
+ goto end;
+ }
+ break;
}
break;
+ }
case CRL_OBJ_ALGORITHM:
{
this->algorithm = asn1_parse_algorithmIdentifier(object, level, NULL);
@@ -344,6 +390,26 @@ METHOD(crl_t, get_authKeyIdentifier, chunk_t,
return this->authKeyIdentifier;
}
+METHOD(crl_t, is_delta_crl, bool,
+ private_x509_crl_t *this, chunk_t *base_crl)
+{
+ if (this->baseCrlNumber.len)
+ {
+ if (base_crl)
+ {
+ *base_crl = this->baseCrlNumber;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+METHOD(crl_t, create_delta_crl_uri_enumerator, enumerator_t*,
+ private_x509_crl_t *this)
+{
+ return this->crl_uris->create_enumerator(this->crl_uris);
+}
+
METHOD(crl_t, create_enumerator, enumerator_t*,
private_x509_crl_t *this)
{
@@ -388,7 +454,7 @@ METHOD(certificate_t, issued_by, bool,
{
return FALSE;
}
- if (!(x509->get_flags(x509) & X509_CA))
+ if (!(x509->get_flags(x509) & (X509_CA | X509_CRL_SIGN)))
{
return FALSE;
}
@@ -501,18 +567,30 @@ static void revoked_destroy(revoked_t *revoked)
free(revoked);
}
+/**
+ * Destroy a CDP entry
+ */
+static void cdp_destroy(x509_cdp_t *this)
+{
+ free(this->uri);
+ DESTROY_IF(this->issuer);
+ free(this);
+}
+
METHOD(certificate_t, destroy, void,
private_x509_crl_t *this)
{
if (ref_put(&this->ref))
{
this->revoked->destroy_function(this->revoked, (void*)revoked_destroy);
+ this->crl_uris->destroy_function(this->crl_uris, (void*)cdp_destroy);
DESTROY_IF(this->issuer);
free(this->authKeyIdentifier.ptr);
free(this->encoding.ptr);
if (this->generated)
{
free(this->crlNumber.ptr);
+ free(this->baseCrlNumber.ptr);
free(this->signature.ptr);
free(this->tbsCertList.ptr);
}
@@ -546,10 +624,13 @@ static private_x509_crl_t* create_empty(void)
},
.get_serial = _get_serial,
.get_authKeyIdentifier = _get_authKeyIdentifier,
+ .is_delta_crl = _is_delta_crl,
+ .create_delta_crl_uri_enumerator = _create_delta_crl_uri_enumerator,
.create_enumerator = _create_enumerator,
},
},
.revoked = linked_list_create(),
+ .crl_uris = linked_list_create(),
.ref = 1,
);
return this;
@@ -618,6 +699,7 @@ static bool generate(private_x509_crl_t *this, certificate_t *cert,
private_key_t *key, hash_algorithm_t digest_alg)
{
chunk_t extensions = chunk_empty, certList = chunk_empty, serial;
+ chunk_t crlDistributionPoints = chunk_empty, baseCrlNumber = chunk_empty;
enumerator_t *enumerator;
crl_reason_t reason;
time_t date;
@@ -625,7 +707,7 @@ static bool generate(private_x509_crl_t *this, certificate_t *cert,
x509 = (x509_t*)cert;
- this->issuer = cert->get_issuer(cert);
+ this->issuer = cert->get_subject(cert);
this->issuer = this->issuer->clone(this->issuer);
this->authKeyIdentifier = chunk_clone(x509->get_subjectKeyIdentifier(x509));
@@ -660,8 +742,21 @@ static bool generate(private_x509_crl_t *this, certificate_t *cert,
}
enumerator->destroy(enumerator);
+ crlDistributionPoints = x509_build_crlDistributionPoints(this->crl_uris,
+ OID_FRESHEST_CRL);
+
+ if (this->baseCrlNumber.len)
+ {
+ baseCrlNumber = asn1_wrap(ASN1_SEQUENCE, "mmm",
+ asn1_build_known_oid(OID_DELTA_CRL_INDICATOR),
+ asn1_wrap(ASN1_BOOLEAN, "c",
+ chunk_from_chars(0xFF)),
+ asn1_wrap(ASN1_OCTET_STRING, "m",
+ asn1_integer("c", this->baseCrlNumber)));
+ }
+
extensions = asn1_wrap(ASN1_CONTEXT_C_0, "m",
- asn1_wrap(ASN1_SEQUENCE, "mm",
+ asn1_wrap(ASN1_SEQUENCE, "mmmm",
asn1_wrap(ASN1_SEQUENCE, "mm",
asn1_build_known_oid(OID_AUTHORITY_KEY_ID),
asn1_wrap(ASN1_OCTET_STRING, "m",
@@ -671,9 +766,8 @@ static bool generate(private_x509_crl_t *this, certificate_t *cert,
asn1_wrap(ASN1_SEQUENCE, "mm",
asn1_build_known_oid(OID_CRL_NUMBER),
asn1_wrap(ASN1_OCTET_STRING, "m",
- asn1_integer("c", this->crlNumber))
- )
- ));
+ asn1_integer("c", this->crlNumber))),
+ crlDistributionPoints, baseCrlNumber));
this->tbsCertList = asn1_wrap(ASN1_SEQUENCE, "cmcmmmm",
ASN1_INTEGER_1,
@@ -736,6 +830,29 @@ x509_crl_t *x509_crl_gen(certificate_type_t type, va_list args)
case BUILD_REVOKED_ENUMERATOR:
read_revoked(crl, va_arg(args, enumerator_t*));
continue;
+ case BUILD_BASE_CRL:
+ crl->baseCrlNumber = va_arg(args, chunk_t);
+ crl->baseCrlNumber = chunk_clone(crl->baseCrlNumber);
+ break;
+ case BUILD_CRL_DISTRIBUTION_POINTS:
+ {
+ enumerator_t *enumerator;
+ linked_list_t *list;
+ x509_cdp_t *in, *cdp;
+
+ list = va_arg(args, linked_list_t*);
+ enumerator = list->create_enumerator(list);
+ while (enumerator->enumerate(enumerator, &in))
+ {
+ INIT(cdp,
+ .uri = strdup(in->uri),
+ .issuer = in->issuer ? in->issuer->clone(in->issuer) : NULL,
+ );
+ crl->crl_uris->insert_last(crl->crl_uris, cdp);
+ }
+ enumerator->destroy(enumerator);
+ continue;
+ }
case BUILD_END:
break;
default:
diff --git a/src/libstrongswan/plugins/x509/x509_plugin.c b/src/libstrongswan/plugins/x509/x509_plugin.c
index 11a7f023c..d40cc3567 100644
--- a/src/libstrongswan/plugins/x509/x509_plugin.c
+++ b/src/libstrongswan/plugins/x509/x509_plugin.c
@@ -36,10 +36,8 @@ struct private_x509_plugin_t {
x509_plugin_t public;
};
-/**
- * Implementation of x509_plugin_t.x509troy
- */
-static void destroy(private_x509_plugin_t *this)
+METHOD(plugin_t, destroy, void,
+ private_x509_plugin_t *this)
{
lib->creds->remove_builder(lib->creds,
(builder_function_t)x509_cert_gen);
@@ -69,9 +67,15 @@ static void destroy(private_x509_plugin_t *this)
*/
plugin_t *x509_plugin_create()
{
- private_x509_plugin_t *this = malloc_thing(private_x509_plugin_t);
+ private_x509_plugin_t *this;
- this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
+ INIT(this,
+ .public = {
+ .plugin = {
+ .destroy = _destroy,
+ },
+ },
+ );
lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_X509, FALSE,
(builder_function_t)x509_cert_gen);
diff --git a/src/libstrongswan/plugins/xcbc/Makefile.in b/src/libstrongswan/plugins/xcbc/Makefile.in
index e82e5246f..06d7a2121 100644
--- a/src/libstrongswan/plugins/xcbc/Makefile.in
+++ b/src/libstrongswan/plugins/xcbc/Makefile.in
@@ -220,9 +220,7 @@ includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
-ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
-ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -261,6 +259,8 @@ sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
+soup_CFLAGS = @soup_CFLAGS@
+soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
diff --git a/src/libstrongswan/plugins/xcbc/xcbc_plugin.c b/src/libstrongswan/plugins/xcbc/xcbc_plugin.c
index 88156f383..65e88335c 100644
--- a/src/libstrongswan/plugins/xcbc/xcbc_plugin.c
+++ b/src/libstrongswan/plugins/xcbc/xcbc_plugin.c
@@ -19,6 +19,8 @@
#include "xcbc_signer.h"
#include "xcbc_prf.h"
+static const char *plugin_name = "xcbc";
+
typedef struct private_xcbc_plugin_t private_xcbc_plugin_t;
/**
@@ -48,6 +50,7 @@ METHOD(plugin_t, destroy, void,
plugin_t *xcbc_plugin_create()
{
private_xcbc_plugin_t *this;
+ crypter_t *crypter;
INIT(this,
.public = {
@@ -57,15 +60,24 @@ plugin_t *xcbc_plugin_create()
},
);
- lib->crypto->add_prf(lib->crypto, PRF_AES128_XCBC,
- (prf_constructor_t)xcbc_prf_create);
- lib->crypto->add_prf(lib->crypto, PRF_CAMELLIA128_XCBC,
- (prf_constructor_t)xcbc_prf_create);
- lib->crypto->add_signer(lib->crypto, AUTH_AES_XCBC_96,
- (signer_constructor_t)xcbc_signer_create);
- lib->crypto->add_signer(lib->crypto, AUTH_CAMELLIA_XCBC_96,
- (signer_constructor_t)xcbc_signer_create);
-
+ crypter = lib->crypto->create_crypter(lib->crypto, ENCR_AES_CBC, 16);
+ if (crypter)
+ {
+ crypter->destroy(crypter);
+ lib->crypto->add_prf(lib->crypto, PRF_AES128_XCBC, plugin_name,
+ (prf_constructor_t)xcbc_prf_create);
+ lib->crypto->add_signer(lib->crypto, AUTH_AES_XCBC_96, plugin_name,
+ (signer_constructor_t)xcbc_signer_create);
+ }
+ crypter = lib->crypto->create_crypter(lib->crypto, ENCR_CAMELLIA_CBC, 16);
+ if (crypter)
+ {
+ crypter->destroy(crypter);
+ lib->crypto->add_prf(lib->crypto, PRF_CAMELLIA128_XCBC, plugin_name,
+ (prf_constructor_t)xcbc_prf_create);
+ lib->crypto->add_signer(lib->crypto, AUTH_CAMELLIA_XCBC_96, plugin_name,
+ (signer_constructor_t)xcbc_signer_create);
+ }
return &this->public.plugin;
}
diff --git a/src/libstrongswan/printf_hook.c b/src/libstrongswan/printf_hook.c
index 4d4cef829..7e7045d69 100644
--- a/src/libstrongswan/printf_hook.c
+++ b/src/libstrongswan/printf_hook.c
@@ -377,10 +377,8 @@ int vstr_wrapper_vasprintf(char **str, const char *format, va_list args)
}
#endif
-/**
- * Implementation of printf_hook_t.add_handler.
- */
-static void add_handler(private_printf_hook_t *this, char spec,
+METHOD(printf_hook_t, add_handler, void,
+ private_printf_hook_t *this, char spec,
printf_hook_function_t hook, ...)
{
int i = -1;
@@ -439,10 +437,8 @@ static void add_handler(private_printf_hook_t *this, char spec,
}
}
-/**
- * Implementation of printf_hook_t.destroy
- */
-static void destroy(private_printf_hook_t *this)
+METHOD(printf_hook_t, destroy, void,
+ private_printf_hook_t *this)
{
int i;
#ifdef USE_VSTR
@@ -477,10 +473,14 @@ static void destroy(private_printf_hook_t *this)
*/
printf_hook_t *printf_hook_create()
{
- private_printf_hook_t *this = malloc_thing(private_printf_hook_t);
-
- this->public.add_handler = (void(*)(printf_hook_t*, char, printf_hook_function_t, ...))add_handler;
- this->public.destroy = (void(*)(printf_hook_t*))destroy;
+ private_printf_hook_t *this;
+
+ INIT(this,
+ .public = {
+ .add_handler = _add_handler,
+ .destroy = _destroy,
+ },
+ );
memset(printf_hooks, 0, sizeof(printf_hooks));
diff --git a/src/libstrongswan/processing/processor.c b/src/libstrongswan/processing/processor.c
index 2a44f61e8..723aec908 100644
--- a/src/libstrongswan/processing/processor.c
+++ b/src/libstrongswan/processing/processor.c
@@ -248,7 +248,7 @@ static void destroy(private_processor_t *this)
/*
* Described in header.
*/
-processor_t *processor_create(size_t pool_size)
+processor_t *processor_create()
{
private_processor_t *this = malloc_thing(private_processor_t);
diff --git a/src/libstrongswan/selectors/traffic_selector.c b/src/libstrongswan/selectors/traffic_selector.c
index 68bbbe2fd..32da194ef 100644
--- a/src/libstrongswan/selectors/traffic_selector.c
+++ b/src/libstrongswan/selectors/traffic_selector.c
@@ -393,13 +393,15 @@ static bool equals(private_traffic_selector_t *this, private_traffic_selector_t
switch (this->type)
{
case TS_IPV4_ADDR_RANGE:
- if (memeq(this->from4, other->from4, sizeof(this->from4)))
+ if (memeq(this->from4, other->from4, sizeof(this->from4)) &&
+ memeq(this->to4, other->to4, sizeof(this->to4)))
{
return TRUE;
}
break;
case TS_IPV6_ADDR_RANGE:
- if (memeq(this->from6, other->from6, sizeof(this->from6)))
+ if (memeq(this->from6, other->from6, sizeof(this->from6)) &&
+ memeq(this->to6, other->to6, sizeof(this->to6)))
{
return TRUE;
}
diff --git a/src/libstrongswan/settings.c b/src/libstrongswan/settings.c
index d85abb1df..bd279f51d 100644
--- a/src/libstrongswan/settings.c
+++ b/src/libstrongswan/settings.c
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2010 Tobias Brunner
* Copyright (C) 2008 Martin Willi
* Hochschule fuer Technik Rapperswil
*
@@ -18,12 +19,17 @@
#include <stdarg.h>
#include <stdio.h>
#include <errno.h>
+#include <limits.h>
+#include <glob.h>
+#include <libgen.h>
#include "settings.h"
#include "debug.h"
#include "utils/linked_list.h"
+#include "threading/rwlock.h"
+#define MAX_INCLUSION_LEVEL 10
typedef struct private_settings_t private_settings_t;
typedef struct section_t section_t;
@@ -45,9 +51,14 @@ struct private_settings_t {
section_t *top;
/**
- * allocated file text
+ * contents of loaded files and in-memory settings (char*)
*/
- char *text;
+ linked_list_t *contents;
+
+ /**
+ * lock to safely access the settings
+ */
+ rwlock_t *lock;
};
/**
@@ -88,6 +99,69 @@ struct kv_t {
};
/**
+ * create a key/value pair
+ */
+static kv_t *kv_create(char *key, char *value)
+{
+ kv_t *this;
+ INIT(this,
+ .key = strdup(key),
+ .value = value,
+ );
+ return this;
+}
+
+/**
+ * destroy a key/value pair
+ */
+static void kv_destroy(kv_t *this)
+{
+ free(this->key);
+ free(this);
+}
+
+/**
+ * create a section with the given name
+ */
+static section_t *section_create(char *name)
+{
+ section_t *this;
+ INIT(this,
+ .name = strdupnull(name),
+ .sections = linked_list_create(),
+ .kv = linked_list_create(),
+ );
+ return this;
+}
+
+/**
+ * destroy a section
+ */
+static void section_destroy(section_t *this)
+{
+ this->kv->destroy_function(this->kv, (void*)kv_destroy);
+ this->sections->destroy_function(this->sections, (void*)section_destroy);
+ free(this->name);
+ free(this);
+}
+
+/**
+ * callback to find a section by name
+ */
+static bool section_find(section_t *this, char *name)
+{
+ return streq(this->name, name);
+}
+
+/**
+ * callback to find a kv pair by key
+ */
+static bool kv_find(kv_t *this, char *key)
+{
+ return streq(this->key, key);
+}
+
+/**
* Print a format key, but consume already processed arguments
*/
static bool print_key(char *buf, int len, char *start, char *key, va_list args)
@@ -136,14 +210,15 @@ static bool print_key(char *buf, int len, char *start, char *key, va_list args)
}
/**
- * find a section by a given key, using buffered key, reusable buffer
+ * Find a section by a given key, using buffered key, reusable buffer.
+ * If "ensure" is TRUE, the sections are created if they don't exist.
*/
static section_t *find_section_buffered(section_t *section,
- char *start, char *key, va_list args, char *buf, int len)
+ char *start, char *key, va_list args, char *buf, int len,
+ bool ensure)
{
char *pos;
- enumerator_t *enumerator;
- section_t *current, *found = NULL;
+ section_t *found = NULL;
if (section == NULL)
{
@@ -159,47 +234,75 @@ static section_t *find_section_buffered(section_t *section,
{
return NULL;
}
- enumerator = section->sections->create_enumerator(section->sections);
- while (enumerator->enumerate(enumerator, &current))
+ if (section->sections->find_first(section->sections,
+ (linked_list_match_t)section_find,
+ (void**)&found, buf) != SUCCESS)
{
- if (streq(current->name, buf))
+ if (ensure)
{
- found = current;
- break;
+ found = section_create(buf);
+ section->sections->insert_last(section->sections, found);
}
}
- enumerator->destroy(enumerator);
if (found && pos)
{
- return find_section_buffered(found, start, pos, args, buf, len);
+ return find_section_buffered(found, start, pos, args, buf, len, ensure);
}
return found;
}
/**
- * find a section by a given key
+ * Find a section by a given key (thread-safe).
*/
-static section_t *find_section(section_t *section, char *key, va_list args)
+static section_t *find_section(private_settings_t *this, section_t *section,
+ char *key, va_list args)
{
char buf[128], keybuf[512];
+ section_t *found;
if (snprintf(keybuf, sizeof(keybuf), "%s", key) >= sizeof(keybuf))
{
return NULL;
}
- return find_section_buffered(section, keybuf, keybuf, args, buf, sizeof(buf));
+ this->lock->read_lock(this->lock);
+ found = find_section_buffered(section, keybuf, keybuf, args, buf,
+ sizeof(buf), FALSE);
+ this->lock->unlock(this->lock);
+ return found;
}
/**
- * Find the string value for a key, using buffered key, reusable buffer
+ * Ensure that the section with the given key exists (thread-safe).
*/
-static char *find_value_buffered(section_t *section,
- char *start, char *key, va_list args, char *buf, int len)
+static section_t *ensure_section(private_settings_t *this, section_t *section,
+ char *key, va_list args)
{
- char *pos, *value = NULL;
- enumerator_t *enumerator;
- kv_t *kv;
- section_t *current, *found = NULL;
+ char buf[128], keybuf[512];
+ section_t *found;
+
+ if (snprintf(keybuf, sizeof(keybuf), "%s", key) >= sizeof(keybuf))
+ {
+ return NULL;
+ }
+ /* we might have to change the tree */
+ this->lock->write_lock(this->lock);
+ found = find_section_buffered(section, keybuf, keybuf, args, buf,
+ sizeof(buf), TRUE);
+ this->lock->unlock(this->lock);
+ return found;
+}
+
+/**
+ * Find the key/value pair for a key, using buffered key, reusable buffer
+ * If "ensure" is TRUE, the sections (and key/value pair) are created if they
+ * don't exist.
+ */
+static kv_t *find_value_buffered(section_t *section, char *start, char *key,
+ va_list args, char *buf, int len, bool ensure)
+{
+ char *pos;
+ kv_t *kv = NULL;
+ section_t *found = NULL;
if (section == NULL)
{
@@ -216,20 +319,19 @@ static char *find_value_buffered(section_t *section,
{
return NULL;
}
- enumerator = section->sections->create_enumerator(section->sections);
- while (enumerator->enumerate(enumerator, &current))
+ if (section->sections->find_first(section->sections,
+ (linked_list_match_t)section_find,
+ (void**)&found, buf) != SUCCESS)
{
- if (streq(current->name, buf))
+ if (!ensure)
{
- found = current;
- break;
+ return NULL;
}
+ found = section_create(buf);
+ section->sections->insert_last(section->sections, found);
}
- enumerator->destroy(enumerator);
- if (found)
- {
- return find_value_buffered(found, start, pos, args, buf, len);
- }
+ return find_value_buffered(found, start, pos, args, buf, len,
+ ensure);
}
else
{
@@ -237,44 +339,86 @@ static char *find_value_buffered(section_t *section,
{
return NULL;
}
- enumerator = section->kv->create_enumerator(section->kv);
- while (enumerator->enumerate(enumerator, &kv))
+ if (section->kv->find_first(section->kv, (linked_list_match_t)kv_find,
+ (void**)&kv, buf) != SUCCESS)
{
- if (streq(kv->key, buf))
+ if (ensure)
{
- value = kv->value;
- break;
+ kv = kv_create(buf, NULL);
+ section->kv->insert_last(section->kv, kv);
}
}
- enumerator->destroy(enumerator);
}
- return value;
+ return kv;
}
/**
- * Find the string value for a key
+ * Find the string value for a key (thread-safe).
*/
-static char *find_value(section_t *section, char *key, va_list args)
+static char *find_value(private_settings_t *this, section_t *section,
+ char *key, va_list args)
{
- char buf[128], keybuf[512];
+ char buf[128], keybuf[512], *value = NULL;
+ kv_t *kv;
if (snprintf(keybuf, sizeof(keybuf), "%s", key) >= sizeof(keybuf))
{
return NULL;
}
- return find_value_buffered(section, keybuf, keybuf, args, buf, sizeof(buf));
+ this->lock->read_lock(this->lock);
+ kv = find_value_buffered(section, keybuf, keybuf, args, buf, sizeof(buf),
+ FALSE);
+ if (kv)
+ {
+ value = kv->value;
+ }
+ this->lock->unlock(this->lock);
+ return value;
}
/**
- * Implementation of settings_t.get.
+ * Set a value to a copy of the given string (thread-safe).
*/
-static char* get_str(private_settings_t *this, char *key, char *def, ...)
+static void set_value(private_settings_t *this, section_t *section,
+ char *key, va_list args, char *value)
+{
+ char buf[128], keybuf[512];
+ kv_t *kv;
+
+ if (snprintf(keybuf, sizeof(keybuf), "%s", key) >= sizeof(keybuf))
+ {
+ return;
+ }
+ this->lock->write_lock(this->lock);
+ kv = find_value_buffered(section, keybuf, keybuf, args, buf, sizeof(buf),
+ TRUE);
+ if (kv)
+ {
+ if (!value)
+ {
+ kv->value = NULL;
+ }
+ else if (kv->value && (strlen(value) <= strlen(kv->value)))
+ { /* overwrite in-place, if possible */
+ strcpy(kv->value, value);
+ }
+ else
+ { /* otherwise clone the string and store it in the cache */
+ kv->value = strdup(value);
+ this->contents->insert_last(this->contents, kv->value);
+ }
+ }
+ this->lock->unlock(this->lock);
+}
+
+METHOD(settings_t, get_str, char*,
+ private_settings_t *this, char *key, char *def, ...)
{
char *value;
va_list args;
va_start(args, def);
- value = find_value(this->top, key, args);
+ value = find_value(this, this->top, key, args);
va_end(args);
if (value)
{
@@ -284,29 +428,23 @@ static char* get_str(private_settings_t *this, char *key, char *def, ...)
}
/**
- * Implementation of settings_t.get_bool.
+ * Described in header
*/
-static bool get_bool(private_settings_t *this, char *key, bool def, ...)
+inline bool settings_value_as_bool(char *value, bool def)
{
- char *value;
- va_list args;
-
- va_start(args, def);
- value = find_value(this->top, key, args);
- va_end(args);
if (value)
{
- if (strcaseeq(value, "true") ||
- strcaseeq(value, "enabled") ||
+ if (strcaseeq(value, "1") ||
strcaseeq(value, "yes") ||
- strcaseeq(value, "1"))
+ strcaseeq(value, "true") ||
+ strcaseeq(value, "enabled"))
{
return TRUE;
}
- else if (strcaseeq(value, "false") ||
- strcaseeq(value, "disabled") ||
+ else if (strcaseeq(value, "0") ||
strcaseeq(value, "no") ||
- strcaseeq(value, "0"))
+ strcaseeq(value, "false") ||
+ strcaseeq(value, "disabled"))
{
return FALSE;
}
@@ -314,18 +452,24 @@ static bool get_bool(private_settings_t *this, char *key, bool def, ...)
return def;
}
-/**
- * Implementation of settings_t.get_int.
- */
-static int get_int(private_settings_t *this, char *key, int def, ...)
+METHOD(settings_t, get_bool, bool,
+ private_settings_t *this, char *key, bool def, ...)
{
char *value;
- int intval;
va_list args;
va_start(args, def);
- value = find_value(this->top, key, args);
+ value = find_value(this, this->top, key, args);
va_end(args);
+ return settings_value_as_bool(value, def);
+}
+
+/**
+ * Described in header
+ */
+inline int settings_value_as_int(char *value, int def)
+{
+ int intval;
if (value)
{
errno = 0;
@@ -338,18 +482,24 @@ static int get_int(private_settings_t *this, char *key, int def, ...)
return def;
}
-/**
- * Implementation of settings_t.get_double.
- */
-static double get_double(private_settings_t *this, char *key, double def, ...)
+METHOD(settings_t, get_int, int,
+ private_settings_t *this, char *key, int def, ...)
{
char *value;
- double dval;
va_list args;
va_start(args, def);
- value = find_value(this->top, key, args);
+ value = find_value(this, this->top, key, args);
va_end(args);
+ return settings_value_as_int(value, def);
+}
+
+/**
+ * Described in header
+ */
+inline double settings_value_as_double(char *value, double def)
+{
+ double dval;
if (value)
{
errno = 0;
@@ -362,18 +512,25 @@ static double get_double(private_settings_t *this, char *key, double def, ...)
return def;
}
-/**
- * Implementation of settings_t.get_time.
- */
-static u_int32_t get_time(private_settings_t *this, char *key, u_int32_t def, ...)
+METHOD(settings_t, get_double, double,
+ private_settings_t *this, char *key, double def, ...)
{
- char *value, *endptr;
- u_int32_t timeval;
+ char *value;
va_list args;
va_start(args, def);
- value = find_value(this->top, key, args);
+ value = find_value(this, this->top, key, args);
va_end(args);
+ return settings_value_as_double(value, def);
+}
+
+/**
+ * Described in header
+ */
+inline u_int32_t settings_value_as_time(char *value, u_int32_t def)
+{
+ char *endptr;
+ u_int32_t timeval;
if (value)
{
errno = 0;
@@ -392,7 +549,7 @@ static u_int32_t get_time(private_settings_t *this, char *key, u_int32_t def, ..
timeval *= 60;
break;
case 's': /* time in seconds */
- default:
+ default:
break;
}
return timeval;
@@ -401,6 +558,75 @@ static u_int32_t get_time(private_settings_t *this, char *key, u_int32_t def, ..
return def;
}
+METHOD(settings_t, get_time, u_int32_t,
+ private_settings_t *this, char *key, u_int32_t def, ...)
+{
+ char *value;
+ va_list args;
+
+ va_start(args, def);
+ value = find_value(this, this->top, key, args);
+ va_end(args);
+ return settings_value_as_time(value, def);
+}
+
+METHOD(settings_t, set_str, void,
+ private_settings_t *this, char *key, char *value, ...)
+{
+ va_list args;
+ va_start(args, value);
+ set_value(this, this->top, key, args, value);
+ va_end(args);
+}
+
+METHOD(settings_t, set_bool, void,
+ private_settings_t *this, char *key, bool value, ...)
+{
+ va_list args;
+ va_start(args, value);
+ set_value(this, this->top, key, args, value ? "1" : "0");
+ va_end(args);
+}
+
+METHOD(settings_t, set_int, void,
+ private_settings_t *this, char *key, int value, ...)
+{
+ char val[16];
+ va_list args;
+ va_start(args, value);
+ if (snprintf(val, sizeof(val), "%d", value) < sizeof(val))
+ {
+ set_value(this, this->top, key, args, val);
+ }
+ va_end(args);
+}
+
+METHOD(settings_t, set_double, void,
+ private_settings_t *this, char *key, double value, ...)
+{
+ char val[64];
+ va_list args;
+ va_start(args, value);
+ if (snprintf(val, sizeof(val), "%f", value) < sizeof(val))
+ {
+ set_value(this, this->top, key, args, val);
+ }
+ va_end(args);
+}
+
+METHOD(settings_t, set_time, void,
+ private_settings_t *this, char *key, u_int32_t value, ...)
+{
+ char val[16];
+ va_list args;
+ va_start(args, value);
+ if (snprintf(val, sizeof(val), "%u", value) < sizeof(val))
+ {
+ set_value(this, this->top, key, args, val);
+ }
+ va_end(args);
+}
+
/**
* Enumerate section names, not sections
*/
@@ -410,26 +636,24 @@ static bool section_filter(void *null, section_t **in, char **out)
return TRUE;
}
-/**
- * Implementation of settings_t.create_section_enumerator
- */
-static enumerator_t* create_section_enumerator(private_settings_t *this,
- char *key, ...)
+METHOD(settings_t, create_section_enumerator, enumerator_t*,
+ private_settings_t *this, char *key, ...)
{
section_t *section;
va_list args;
va_start(args, key);
- section = find_section(this->top, key, args);
+ section = find_section(this, this->top, key, args);
va_end(args);
if (!section)
{
return enumerator_create_empty();
}
+ this->lock->read_lock(this->lock);
return enumerator_create_filter(
- section->sections->create_enumerator(section->sections),
- (void*)section_filter, NULL, NULL);
+ section->sections->create_enumerator(section->sections),
+ (void*)section_filter, this->lock, (void*)this->lock->unlock);
}
/**
@@ -443,37 +667,24 @@ static bool kv_filter(void *null, kv_t **in, char **key,
return TRUE;
}
-/**
- * Implementation of settings_t.create_key_value_enumerator
- */
-static enumerator_t* create_key_value_enumerator(private_settings_t *this,
- char *key, ...)
+METHOD(settings_t, create_key_value_enumerator, enumerator_t*,
+ private_settings_t *this, char *key, ...)
{
section_t *section;
va_list args;
va_start(args, key);
- section = find_section(this->top, key, args);
+ section = find_section(this, this->top, key, args);
va_end(args);
if (!section)
{
return enumerator_create_empty();
}
+ this->lock->read_lock(this->lock);
return enumerator_create_filter(
section->kv->create_enumerator(section->kv),
- (void*)kv_filter, NULL, NULL);
-}
-
-/**
- * destroy a section
- */
-static void section_destroy(section_t *this)
-{
- this->kv->destroy_function(this->kv, free);
- this->sections->destroy_function(this->sections, (void*)section_destroy);
-
- free(this);
+ (void*)kv_filter, this->lock, (void*)this->lock->unlock);
}
/**
@@ -551,45 +762,134 @@ static char parse(char **text, char *skip, char *term, char *br, char **token)
}
/**
+ * Check if "text" starts with "pattern".
+ * Characters in "skip" are skipped first. If found, TRUE is returned and "text"
+ * is modified to point to the character right after "pattern".
+ */
+static bool starts_with(char **text, char *skip, char *pattern)
+{
+ char *pos = *text;
+ int len = strlen(pattern);
+ while (strchr(skip, *pos))
+ {
+ pos++;
+ if (!*pos)
+ {
+ return FALSE;
+ }
+ }
+ if (strlen(pos) < len || !strneq(pos, pattern, len))
+ {
+ return FALSE;
+ }
+ *text = pos + len;
+ return TRUE;
+}
+
+/**
+ * Check if what follows in "text" is an include statement.
+ * If this function returns TRUE, "text" will point to the character right after
+ * the include pattern, which is returned in "pattern".
+ */
+static bool parse_include(char **text, char **pattern)
+{
+ char *pos = *text;
+ if (!starts_with(&pos, "\n\t ", "include"))
+ {
+ return FALSE;
+ }
+ if (starts_with(&pos, "\t ", "="))
+ { /* ignore "include = value" */
+ return FALSE;
+ }
+ *text = pos;
+ return parse(text, "\t ", "\n", NULL, pattern) != 0;
+}
+
+/**
+ * Forward declaration.
+ */
+static bool parse_files(linked_list_t *contents, char *file, int level,
+ char *pattern, section_t *section);
+
+/**
* Parse a section
*/
-static section_t* parse_section(char **text, char *name)
+static bool parse_section(linked_list_t *contents, char *file, int level,
+ char **text, section_t *section)
{
- section_t *sub, *section;
bool finished = FALSE;
char *key, *value, *inner;
- static int lev = 0;
- lev++;
-
- section = malloc_thing(section_t);
- section->name = name;
- section->sections = linked_list_create();
- section->kv = linked_list_create();
-
while (!finished)
{
+ if (parse_include(text, &value))
+ {
+ if (!parse_files(contents, file, level, value, section))
+ {
+ DBG1(DBG_LIB, "failed to include '%s'", value);
+ return FALSE;
+ }
+ continue;
+ }
switch (parse(text, "\t\n ", "{=#", NULL, &key))
{
case '{':
if (parse(text, "\t ", "}", "{", &inner))
{
- sub = parse_section(&inner, key);
- if (sub)
+ section_t *sub;
+ if (!strlen(key))
{
- section->sections->insert_last(section->sections, sub);
+ DBG1(DBG_LIB, "skipping section without name in '%s'",
+ section->name);
continue;
}
+ if (section->sections->find_first(section->sections,
+ (linked_list_match_t)section_find,
+ (void**)&sub, key) != SUCCESS)
+ {
+ sub = section_create(key);
+ if (parse_section(contents, file, level, &inner, sub))
+ {
+ section->sections->insert_last(section->sections,
+ sub);
+ continue;
+ }
+ section_destroy(sub);
+ }
+ else
+ { /* extend the existing section */
+ if (parse_section(contents, file, level, &inner, sub))
+ {
+ continue;
+ }
+ }
+ DBG1(DBG_LIB, "parsing subsection '%s' failed", key);
+ break;
}
DBG1(DBG_LIB, "matching '}' not found near %s", *text);
break;
case '=':
if (parse(text, "\t ", "\n", NULL, &value))
{
- kv_t *kv = malloc_thing(kv_t);
- kv->key = key;
- kv->value = value;
- section->kv->insert_last(section->kv, kv);
+ kv_t *kv;
+ if (!strlen(key))
+ {
+ DBG1(DBG_LIB, "skipping value without key in '%s'",
+ section->name);
+ continue;
+ }
+ if (section->kv->find_first(section->kv,
+ (linked_list_match_t)kv_find,
+ (void**)&kv, key) != SUCCESS)
+ {
+ kv = kv_create(key, value);
+ section->kv->insert_last(section->kv, kv);
+ }
+ else
+ { /* replace with the most recently read value */
+ kv->value = value;
+ }
continue;
}
DBG1(DBG_LIB, "parsing value failed near %s", *text);
@@ -601,78 +901,272 @@ static section_t* parse_section(char **text, char *name)
finished = TRUE;
continue;
}
- section_destroy(section);
- return NULL;
+ return FALSE;
}
- return section;
+ return TRUE;
}
/**
- * Implementation of settings_t.destroy
+ * Parse a file and add the settings to the given section.
*/
-static void destroy(private_settings_t *this)
+static bool parse_file(linked_list_t *contents, char *file, int level,
+ section_t *section)
{
- if (this->top)
+ bool success;
+ char *text, *pos;
+ FILE *fd;
+ int len;
+
+ DBG2(DBG_LIB, "loading config file '%s'", file);
+ fd = fopen(file, "r");
+ if (fd == NULL)
{
- section_destroy(this->top);
+ DBG1(DBG_LIB, "'%s' does not exist or is not readable", file);
+ return FALSE;
}
- free(this->text);
- free(this);
+ fseek(fd, 0, SEEK_END);
+ len = ftell(fd);
+ rewind(fd);
+ text = malloc(len + 1);
+ text[len] = '\0';
+ if (fread(text, 1, len, fd) != len)
+ {
+ free(text);
+ return FALSE;
+ }
+ fclose(fd);
+
+ pos = text;
+ success = parse_section(contents, file, level, &pos, section);
+ if (!success)
+ {
+ free(text);
+ }
+ else
+ {
+ contents->insert_last(contents, text);
+ }
+ return success;
}
-/*
- * see header file
+/**
+ * Load the files matching "pattern", which is resolved with glob(3).
+ * If the pattern is relative, the directory of "file" is used as base.
*/
-settings_t *settings_create(char *file)
+static bool parse_files(linked_list_t *contents, char *file, int level,
+ char *pattern, section_t *section)
{
- private_settings_t *this;
- char *pos;
- FILE *fd;
- int len;
+ bool success = TRUE;
+ int status;
+ glob_t buf;
+ char **expanded, pat[PATH_MAX];
- this = malloc_thing(private_settings_t);
- this->public.get_str = (char*(*)(settings_t*, char *key, char* def, ...))get_str;
- this->public.get_int = (int(*)(settings_t*, char *key, int def, ...))get_int;
- this->public.get_double = (double(*)(settings_t*, char *key, double def, ...))get_double;
- this->public.get_time = (u_int32_t(*)(settings_t*, char *key, u_int32_t def, ...))get_time;
- this->public.get_bool = (bool(*)(settings_t*, char *key, bool def, ...))get_bool;
- this->public.create_section_enumerator = (enumerator_t*(*)(settings_t*,char *section, ...))create_section_enumerator;
- this->public.create_key_value_enumerator = (enumerator_t*(*)(settings_t*, char *key, ...))create_key_value_enumerator;
- this->public.destroy = (void(*)(settings_t*))destroy;
+ if (level > MAX_INCLUSION_LEVEL)
+ {
+ DBG1(DBG_LIB, "maximum level of %d includes reached, ignored",
+ MAX_INCLUSION_LEVEL);
+ return TRUE;
+ }
- this->top = NULL;
- this->text = NULL;
+ if (!strlen(pattern))
+ {
+ DBG2(DBG_LIB, "empty include pattern, ignored");
+ return TRUE;
+ }
- if (file == NULL)
+ if (!file || pattern[0] == '/')
+ { /* absolute path */
+ if (snprintf(pat, sizeof(pat), "%s", pattern) >= sizeof(pat))
+ {
+ DBG1(DBG_LIB, "include pattern too long, ignored");
+ return TRUE;
+ }
+ }
+ else
+ { /* base relative paths to the directory of the current file */
+ char *dir = strdup(file);
+ dir = dirname(dir);
+ if (snprintf(pat, sizeof(pat), "%s/%s", dir, pattern) >= sizeof(pat))
+ {
+ DBG1(DBG_LIB, "include pattern too long, ignored");
+ free(dir);
+ return TRUE;
+ }
+ free(dir);
+ }
+ status = glob(pat, GLOB_ERR, NULL, &buf);
+ if (status == GLOB_NOMATCH)
{
- file = STRONGSWAN_CONF;
+ DBG2(DBG_LIB, "no files found matching '%s', ignored", pat);
}
- fd = fopen(file, "r");
- if (fd == NULL)
+ else if (status != 0)
{
- DBG1(DBG_LIB, "'%s' does not exist or is not readable", file);
- return &this->public;
+ DBG1(DBG_LIB, "expanding file pattern '%s' failed", pat);
+ success = FALSE;
}
- fseek(fd, 0, SEEK_END);
- len = ftell(fd);
- rewind(fd);
- this->text = malloc(len + 1);
- this->text[len] = '\0';
- if (fread(this->text, 1, len, fd) != len)
+ else
{
- free(this->text);
- this->text = NULL;
- return &this->public;
+ for (expanded = buf.gl_pathv; *expanded != NULL; expanded++)
+ {
+ success &= parse_file(contents, *expanded, level + 1, section);
+ if (!success)
+ {
+ break;
+ }
+ }
}
- fclose(fd);
+ globfree(&buf);
+ return success;
+}
+
+/**
+ * Recursivly extends "base" with "extension".
+ */
+static void section_extend(section_t *base, section_t *extension)
+{
+ enumerator_t *enumerator;
+ section_t *sec;
+ kv_t *kv;
+
+ enumerator = extension->sections->create_enumerator(extension->sections);
+ while (enumerator->enumerate(enumerator, (void**)&sec))
+ {
+ section_t *found;
+ if (base->sections->find_first(base->sections,
+ (linked_list_match_t)section_find, (void**)&found,
+ sec->name) == SUCCESS)
+ {
+ section_extend(found, sec);
+ }
+ else
+ {
+ extension->sections->remove_at(extension->sections, enumerator);
+ base->sections->insert_last(base->sections, sec);
+ }
+ }
+ enumerator->destroy(enumerator);
+
+ enumerator = extension->kv->create_enumerator(extension->kv);
+ while (enumerator->enumerate(enumerator, (void**)&kv))
+ {
+ kv_t *found;
+ if (base->kv->find_first(base->kv, (linked_list_match_t)kv_find,
+ (void**)&found, kv->key) == SUCCESS)
+ {
+ found->value = kv->value;
+ }
+ else
+ {
+ extension->kv->remove_at(extension->kv, enumerator);
+ base->kv->insert_last(base->kv, kv);
+ }
+ }
+ enumerator->destroy(enumerator);
+}
+
+/**
+ * Load settings from files matching the given file pattern.
+ * All sections and values are added relative to "parent".
+ * All files (even included ones) have to be loaded successfully.
+ */
+static bool load_files_internal(private_settings_t *this, section_t *parent,
+ char *pattern)
+{
+ char *text;
+ linked_list_t *contents = linked_list_create();
+ section_t *section = section_create(NULL);
+
+ if (!parse_files(contents, NULL, 0, pattern, section))
+ {
+ contents->destroy_function(contents, (void*)free);
+ section_destroy(section);
+ return FALSE;
+ }
+
+ this->lock->write_lock(this->lock);
+ /* extend parent section */
+ section_extend(parent, section);
+ /* move contents of loaded files to main store */
+ while (contents->remove_first(contents, (void**)&text) == SUCCESS)
+ {
+ this->contents->insert_last(this->contents, text);
+ }
+ this->lock->unlock(this->lock);
+
+ section_destroy(section);
+ contents->destroy(contents);
+ return TRUE;
+}
+
+METHOD(settings_t, load_files, bool,
+ private_settings_t *this, char *pattern)
+{
+ return load_files_internal(this, this->top, pattern);
+}
+
+METHOD(settings_t, load_files_section, bool,
+ private_settings_t *this, char *pattern, char *key, ...)
+{
+ section_t *section;
+ va_list args;
+
+ va_start(args, key);
+ section = ensure_section(this, this->top, key, args);
+ va_end(args);
- pos = this->text;
- this->top = parse_section(&pos, NULL);
- if (this->top == NULL)
+ if (!section)
{
- free(this->text);
- this->text = NULL;
+ return FALSE;
}
+ return load_files_internal(this, section, pattern);
+}
+
+METHOD(settings_t, destroy, void,
+ private_settings_t *this)
+{
+ section_destroy(this->top);
+ this->contents->destroy_function(this->contents, (void*)free);
+ this->lock->destroy(this->lock);
+ free(this);
+}
+
+/*
+ * see header file
+ */
+settings_t *settings_create(char *file)
+{
+ private_settings_t *this;
+
+ INIT(this,
+ .public = {
+ .get_str = _get_str,
+ .get_int = _get_int,
+ .get_double = _get_double,
+ .get_time = _get_time,
+ .get_bool = _get_bool,
+ .set_str = _set_str,
+ .set_int = _set_int,
+ .set_double = _set_double,
+ .set_time = _set_time,
+ .set_bool = _set_bool,
+ .create_section_enumerator = _create_section_enumerator,
+ .create_key_value_enumerator = _create_key_value_enumerator,
+ .load_files = _load_files,
+ .load_files_section = _load_files_section,
+ .destroy = _destroy,
+ },
+ .top = section_create(NULL),
+ .contents = linked_list_create(),
+ .lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
+ );
+
+ if (file == NULL)
+ {
+ file = STRONGSWAN_CONF;
+ }
+
+ load_files(this, file);
+
return &this->public;
}
diff --git a/src/libstrongswan/settings.h b/src/libstrongswan/settings.h
index 486de8def..bc3df3706 100644
--- a/src/libstrongswan/settings.h
+++ b/src/libstrongswan/settings.h
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2010 Tobias Brunner
* Copyright (C) 2008 Martin Willi
* Hochschule fuer Technik Rapperswil
*
@@ -27,14 +28,54 @@ typedef struct settings_t settings_t;
#include "utils/enumerator.h"
/**
+ * Convert a string value returned by a key/value enumerator to a boolean.
+ *
+ * @see settings_t.create_key_value_enumerator()
+ * @see settings_t.get_bool()
+ * @param value the string value
+ * @param def the default value, if value is NULL or invalid
+ */
+bool settings_value_as_bool(char *value, bool def);
+
+/**
+ * Convert a string value returned by a key/value enumerator to an integer.
+ *
+ * @see settings_t.create_key_value_enumerator()
+ * @see settings_t.get_int()
+ * @param value the string value
+ * @param def the default value, if value is NULL or invalid
+ */
+int settings_value_as_int(char *value, int def);
+
+/**
+ * Convert a string value returned by a key/value enumerator to a double.
+ *
+ * @see settings_t.create_key_value_enumerator()
+ * @see settings_t.get_double()
+ * @param value the string value
+ * @param def the default value, if value is NULL or invalid
+ */
+double settings_value_as_double(char *value, double def);
+
+/**
+ * Convert a string value returned by a key/value enumerator to a time value.
+ *
+ * @see settings_t.create_key_value_enumerator()
+ * @see settings_t.get_time()
+ * @param value the string value
+ * @param def the default value, if value is NULL or invalid
+ */
+u_int32_t settings_value_as_time(char *value, u_int32_t def);
+
+/**
* Generic configuration options read from a config file.
*
* The syntax is quite simple:
- *
+ * @code
* settings := (section|keyvalue)*
* section := name { settings }
* keyvalue := key = value\n
- *
+ * @endcode
* E.g.:
* @code
a = b
@@ -54,6 +95,51 @@ typedef struct settings_t settings_t;
*
* Currently only a limited set of printf format specifiers are supported
* (namely %s, %d and %N, see implementation for details).
+ *
+ * \section includes Including other files
+ * Other files can be included, using the include statement e.g.
+ * @code
+ * include /somepath/subconfig.conf
+ * @endcode
+ * Shell patterns like *.conf are possible.
+ *
+ * If the path is relative, the directory of the file containing the include
+ * statement is used as base.
+ *
+ * Sections loaded from included files extend previously loaded sections,
+ * already existing values are replaced.
+ *
+ * All settings included from files are added relative to the section the
+ * include statment is in.
+ *
+ * The following files result in the same final config as above:
+ *
+ * @code
+ a = b
+ section-one {
+ somevalue = before include
+ include include.conf
+ }
+ include two.conf
+ @endcode
+ * include.conf
+ * @code
+ somevalue = asdf
+ subsection {
+ othervalue = yyy
+ }
+ yetanother = zz
+ @endcode
+ * two.conf
+ * @code
+ section-one {
+ subsection {
+ othervalue = xxx
+ }
+ }
+ section-two {
+ }
+ @endcode
*/
struct settings_t {
@@ -108,6 +194,51 @@ struct settings_t {
u_int32_t (*get_time)(settings_t *this, char *key, u_int32_t def, ...);
/**
+ * Set a string value.
+ *
+ * @param key key including sections, printf style format
+ * @param value value to set (gets cloned)
+ * @param ... argument list for key
+ */
+ void (*set_str)(settings_t *this, char *key, char *value, ...);
+
+ /**
+ * Set a boolean value.
+ *
+ * @param key key including sections, printf style format
+ * @param value value to set
+ * @param ... argument list for key
+ */
+ void (*set_bool)(settings_t *this, char *key, bool value, ...);
+
+ /**
+ * Set an integer value.
+ *
+ * @param key key including sections, printf style format
+ * @param value value to set
+ * @param ... argument list for key
+ */
+ void (*set_int)(settings_t *this, char *key, int value, ...);
+
+ /**
+ * Set an double value.
+ *
+ * @param key key including sections, printf style format
+ * @param value value to set
+ * @param ... argument list for key
+ */
+ void (*set_double)(settings_t *this, char *key, double value, ...);
+
+ /**
+ * Set a time value.
+ *
+ * @param key key including sections, printf style format
+ * @param def value to set
+ * @param ... argument list for key
+ */
+ void (*set_time)(settings_t *this, char *key, u_int32_t value, ...);
+
+ /**
* Create an enumerator over subsection names of a section.
*
* @param section section including parents, printf style format
@@ -121,13 +252,47 @@ struct settings_t {
* Create an enumerator over key/value pairs in a section.
*
* @param section section name to list key/value pairs of, printf style
- * @param ... argmuent list for section
+ * @param ... argument list for section
* @return enumerator over (char *key, char *value)
*/
enumerator_t* (*create_key_value_enumerator)(settings_t *this,
char *section, ...);
/**
+ * Load settings from the files matching the given pattern.
+ *
+ * Existing sections are extended, existing values replaced, by those found
+ * in the loaded files.
+ *
+ * @note If any of the files matching the pattern fails to load, no settings
+ * are added at all. So, it's all or nothing.
+ *
+ * @param pattern file pattern
+ * @return TRUE, if settings were loaded successfully
+ */
+ bool (*load_files)(settings_t *this, char *pattern);
+
+ /**
+ * Load settings from the files matching the given pattern.
+ *
+ * Existing sections are extended, existing values replaced, by those found
+ * in the loaded files.
+ *
+ * All settings are loaded relative to the given section. The section is
+ * created, if it does not yet exist.
+ *
+ * @note If any of the files matching the pattern fails to load, no settings
+ * are added at all. So, it's all or nothing.
+ *
+ * @param pattern file pattern
+ * @param section section name of parent section, printf style
+ * @param ... argument list for section
+ * @return TRUE, if settings were loaded successfully
+ */
+ bool (*load_files_section)(settings_t *this, char *pattern,
+ char *section, ...);
+
+ /**
* Destroy a settings instance.
*/
void (*destroy)(settings_t *this);
diff --git a/src/libstrongswan/utils.c b/src/libstrongswan/utils.c
index b868d538d..2ab061a74 100644
--- a/src/libstrongswan/utils.c
+++ b/src/libstrongswan/utils.c
@@ -247,6 +247,14 @@ bool return_false()
}
/**
+ * returns FAILED
+ */
+status_t return_failed()
+{
+ return FAILED;
+}
+
+/**
* nop operation
*/
void nop()
diff --git a/src/libstrongswan/utils.h b/src/libstrongswan/utils.h
index 35d3bebd1..ed61895ee 100644
--- a/src/libstrongswan/utils.h
+++ b/src/libstrongswan/utils.h
@@ -57,7 +57,7 @@
#define streq(x,y) (strcmp(x, y) == 0)
/**
- * Macro compares two strings for equality
+ * Macro compares two strings for equality, length limited
*/
#define strneq(x,y,len) (strncmp(x, y, len) == 0)
@@ -67,6 +67,16 @@
#define strcaseeq(x,y) (strcasecmp(x, y) == 0)
/**
+ * Macro compares two strings for equality ignoring case, length limited
+ */
+#define strncaseeq(x,y,len) (strncasecmp(x, y, len) == 0)
+
+/**
+ * NULL-safe strdup variant
+ */
+#define strdupnull(x) ({ char *_x = x; _x ? strdup(_x) : NULL; })
+
+/**
* Macro compares two binary blobs for equality
*/
#define memeq(x,y,len) (memcmp(x, y, len) == 0)
@@ -382,6 +392,11 @@ bool return_true();
bool return_false();
/**
+ * returns FAILED
+ */
+status_t return_failed();
+
+/**
* Write a 16-bit host order value in network order to an unaligned address.
*
* @param host host order 16-bit value
diff --git a/src/libstrongswan/utils/backtrace.c b/src/libstrongswan/utils/backtrace.c
index a67245194..41224e8c2 100644
--- a/src/libstrongswan/utils/backtrace.c
+++ b/src/libstrongswan/utils/backtrace.c
@@ -132,10 +132,11 @@ static void log_(private_backtrace_t *this, FILE *file, bool detailed)
/**
* Implementation of backtrace_t.contains_function
*/
-static bool contains_function(private_backtrace_t *this, char *function)
+static bool contains_function(private_backtrace_t *this,
+ char *function[], int count)
{
#ifdef HAVE_DLADDR
- int i;
+ int i, j;
for (i = 0; i< this->frame_count; i++)
{
@@ -143,9 +144,12 @@ static bool contains_function(private_backtrace_t *this, char *function)
if (dladdr(this->frames[i], &info) && info.dli_sname)
{
- if (streq(info.dli_sname, function))
+ for (j = 0; j < count; j++)
{
- return TRUE;
+ if (streq(info.dli_sname, function[j]))
+ {
+ return TRUE;
+ }
}
}
}
@@ -179,7 +183,7 @@ backtrace_t *backtrace_create(int skip)
this->frame_count = frame_count;
this->public.log = (void(*)(backtrace_t*,FILE*,bool))log_;
- this->public.contains_function = (bool(*)(backtrace_t*, char *function))contains_function;
+ this->public.contains_function = (bool(*)(backtrace_t*, char *function[], int count))contains_function;
this->public.destroy = (void(*)(backtrace_t*))destroy;
return &this->public;
diff --git a/src/libstrongswan/utils/backtrace.h b/src/libstrongswan/utils/backtrace.h
index c6b0ec78f..e8ccfc1bd 100644
--- a/src/libstrongswan/utils/backtrace.h
+++ b/src/libstrongswan/utils/backtrace.h
@@ -41,12 +41,13 @@ struct backtrace_t {
void (*log)(backtrace_t *this, FILE *file, bool detailed);
/**
- * Check if the backtrace contains a frame in a specific function.
+ * Check if the backtrace contains a frame having a function in a list.
*
- * @param function name
- * @return TRUE if function is in the stack
+ * @param function name array
+ * @param number of elements in function array
+ * @return TRUE if one of the functions is in the stack
*/
- bool (*contains_function)(backtrace_t *this, char *function);
+ bool (*contains_function)(backtrace_t *this, char *function[], int count);
/**
* Destroy a backtrace instance.
diff --git a/src/libstrongswan/utils/hashtable.c b/src/libstrongswan/utils/hashtable.c
index dde57dc65..49b0bb68c 100644
--- a/src/libstrongswan/utils/hashtable.c
+++ b/src/libstrongswan/utils/hashtable.c
@@ -186,7 +186,7 @@ static void rehash(private_hashtable_t *this)
linked_list_t **old_table;
u_int row, old_capacity;
- if (this->capacity < MAX_CAPACITY)
+ if (this->capacity >= MAX_CAPACITY)
{
return;
}
@@ -249,6 +249,7 @@ METHOD(hashtable_t, put, void*,
{
old_value = pair->value;
pair->value = value;
+ pair->key = key;
break;
}
}
diff --git a/src/libstrongswan/utils/host.c b/src/libstrongswan/utils/host.c
index 112d07e5c..ffeebd05c 100644
--- a/src/libstrongswan/utils/host.c
+++ b/src/libstrongswan/utils/host.c
@@ -476,6 +476,10 @@ host_t *host_create_from_dns(char *string, int af, u_int16_t port)
{
return host_create_any_port(af ? af : AF_INET6, port);
}
+ if (af == AF_INET && strchr(string, ':'))
+ { /* do not try to convert v6 addresses for v4 family */
+ return NULL;
+ }
memset(&hints, 0, sizeof(hints));
hints.ai_family = af;
@@ -564,6 +568,41 @@ host_t *host_create_from_chunk(int family, chunk_t address, u_int16_t port)
/*
* Described in header.
*/
+host_t *host_create_from_subnet(char *string, int *bits)
+{
+ char *pos, buf[64];
+ host_t *net;
+
+ pos = strchr(string, '/');
+ if (pos)
+ {
+ if (pos - string >= sizeof(buf))
+ {
+ return NULL;
+ }
+ strncpy(buf, string, pos - string);
+ buf[pos - string] = '\0';
+ *bits = atoi(pos + 1);
+ return host_create_from_string(buf, 0);
+ }
+ net = host_create_from_string(buf, 0);
+ if (net)
+ {
+ if (net->get_family(net) == AF_INET)
+ {
+ *bits = 32;
+ }
+ else
+ {
+ *bits = 128;
+ }
+ }
+ return net;
+}
+
+/*
+ * Described in header.
+ */
host_t *host_create_any(int family)
{
private_host_t *this = host_create_empty();
diff --git a/src/libstrongswan/utils/host.h b/src/libstrongswan/utils/host.h
index f5796154c..0a1be6e47 100644
--- a/src/libstrongswan/utils/host.h
+++ b/src/libstrongswan/utils/host.h
@@ -190,6 +190,15 @@ host_t *host_create_from_chunk(int family, chunk_t address, u_int16_t port);
host_t *host_create_from_sockaddr(sockaddr_t *sockaddr);
/**
+ * Create a host from a CIDR subnet definition (1.2.3.0/24), return bits.
+ *
+ * @param string string to parse
+ * @param bits gets the number of network bits in CIDR notation
+ * @return network start address, NULL on error
+ */
+host_t *host_create_from_subnet(char *string, int *bits);
+
+/**
* Create a host without an address, a "any" host.
*
* @param family family of the any host
diff --git a/src/libstrongswan/utils/identification.c b/src/libstrongswan/utils/identification.c
index 0696c1030..fd2716deb 100644
--- a/src/libstrongswan/utils/identification.c
+++ b/src/libstrongswan/utils/identification.c
@@ -281,11 +281,13 @@ static void dntoa(chunk_t dn, char *buf, size_t len)
chunk_t oid_data, data, printable;
u_char type;
int oid, written;
- bool finished = FALSE;
+ bool finished = FALSE, empty = TRUE;
e = create_rdn_enumerator(dn);
while (e->enumerate(e, &oid_data, &type, &data))
{
+ empty = FALSE;
+
oid = asn1_known_oid(oid_data);
if (oid == OID_UNKNOWN)
@@ -329,7 +331,11 @@ static void dntoa(chunk_t dn, char *buf, size_t len)
break;
}
}
- if (!finished)
+ if (empty)
+ {
+ snprintf(buf, len, "");
+ }
+ else if (!finished)
{
snprintf(buf, len, "(invalid ID_DER_ASN1_DN)");
}
diff --git a/src/libstrongswan/utils/leak_detective.c b/src/libstrongswan/utils/leak_detective.c
index 5673fc32d..52e92951b 100644
--- a/src/libstrongswan/utils/leak_detective.c
+++ b/src/libstrongswan/utils/leak_detective.c
@@ -218,25 +218,23 @@ char *whitelist[] = {
"gcry_create_nonce",
/* NSPR */
"PR_CallOnce",
+ /* libapr */
+ "apr_pool_create_ex",
+ /* glib */
+ "g_type_init_with_debug_flags",
+ "g_type_register_static",
+ "g_type_class_ref",
+ "g_type_create_instance",
+ "g_type_add_interface_static",
+ "g_type_interface_add_prerequisite",
+ "g_socket_connection_factory_lookup_type",
+ /* libgpg */
+ "gpg_err_init",
+ /* gnutls */
+ "gnutls_global_init",
};
/**
- * check if a stack frame contains functions listed above
- */
-static bool is_whitelisted(backtrace_t *backtrace)
-{
- int i;
- for (i = 0; i < sizeof(whitelist)/sizeof(char*); i++)
- {
- if (backtrace->contains_function(backtrace, whitelist[i]))
- {
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
* Report leaks at library destruction
*/
static void report(private_leak_detective_t *this, bool detailed)
@@ -248,7 +246,8 @@ static void report(private_leak_detective_t *this, bool detailed)
for (hdr = first_header.next; hdr != NULL; hdr = hdr->next)
{
- if (is_whitelisted(hdr->backtrace))
+ if (hdr->backtrace->contains_function(hdr->backtrace,
+ whitelist, countof(whitelist)))
{
whitelisted++;
}
diff --git a/src/libstrongswan/utils/optionsfrom.c b/src/libstrongswan/utils/optionsfrom.c
index d8f635c62..e51780290 100644
--- a/src/libstrongswan/utils/optionsfrom.c
+++ b/src/libstrongswan/utils/optionsfrom.c
@@ -61,11 +61,8 @@ struct private_options_t {
char *buffers[MAX_USES];
};
-/**
- * Defined in header
- */
-bool from(private_options_t *this, char *filename, int *argcp, char **argvp[],
- int optind)
+METHOD(options_t, from, bool,
+ private_options_t *this, char *filename, int *argcp, char **argvp[], int optind)
{
int newargc;
int next; /* place for next argument */
@@ -182,10 +179,8 @@ bool from(private_options_t *this, char *filename, int *argcp, char **argvp[],
return good;
}
-/**
- * Defined in header
- */
-void destroy(private_options_t *this)
+METHOD(options_t, destroy, void,
+ private_options_t *this)
{
while (this->nuses >= 0)
{
@@ -200,17 +195,16 @@ void destroy(private_options_t *this)
*/
options_t *options_create(void)
{
- private_options_t *this = malloc_thing(private_options_t);
+ private_options_t *this;
- /* initialize */
- this->newargv = NULL;
- this->room = 0;
- this->nuses = -1;
- memset(this->buffers, '\0', MAX_USES);
+ INIT(this,
+ .public = {
+ .from = _from,
+ .destroy = _destroy,
- /* public functions */
- this->public.from = (bool (*) (options_t*,char*,int*,char***,int))from;
- this->public.destroy = (void (*) (options_t*))destroy;
+ },
+ .nuses = -1,
+ );
return &this->public;
}