diff options
author | Yves-Alexis Perez <corsac@debian.org> | 2015-10-22 11:43:58 +0200 |
---|---|---|
committer | Yves-Alexis Perez <corsac@debian.org> | 2015-10-22 11:43:58 +0200 |
commit | 5dca9ea0e2931f0e2a056c7964d311bcc30a01b8 (patch) | |
tree | 037f1ec5bb860846938ddcf29771c24e9c529be0 /src/charon-tkm | |
parent | b238cf34df3fe4476ae6b7012e7cb3e9769d4d51 (diff) | |
download | vyos-strongswan-5dca9ea0e2931f0e2a056c7964d311bcc30a01b8.tar.gz vyos-strongswan-5dca9ea0e2931f0e2a056c7964d311bcc30a01b8.zip |
Imported Upstream version 5.3.3
Diffstat (limited to 'src/charon-tkm')
-rw-r--r-- | src/charon-tkm/src/tkm/tkm_encoder.c~ | 106 | ||||
-rw-r--r-- | src/charon-tkm/tests/tests.c | 4 |
2 files changed, 2 insertions, 108 deletions
diff --git a/src/charon-tkm/src/tkm/tkm_encoder.c~ b/src/charon-tkm/src/tkm/tkm_encoder.c~ deleted file mode 100644 index 145615f14..000000000 --- a/src/charon-tkm/src/tkm/tkm_encoder.c~ +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2013 Reto Buerki - * Copyright (C) 2013 Adrian-Ken Rueegsegger - * Hochschule fuer Technik Rapperswil - * - * 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 <utils/debug.h> -#include <asn1/asn1.h> -#include <asn1/oid.h> - -#include "tkm_encoder.h" - -/** - * Build the SHA1 hash of pubkey(info) ASN.1 data. - */ -static bool hash_pubkey(chunk_t pubkey, chunk_t *hash) -{ - hasher_t *hasher; - - hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1); - if (!hasher || !hasher->allocate_hash(hasher, pubkey, hash)) - { - DBG1(DBG_LIB, "SHA1 hash algorithm not supported, " - "fingerprinting failed"); - DESTROY_IF(hasher); - chunk_free(&pubkey); - return FALSE; - } - hasher->destroy(hasher); - chunk_free(&pubkey); - return TRUE; -} - -/** - * Encode the public key blob into subjectPublicKeyInfo. - */ -static bool build_pub_info(chunk_t *encoding, va_list args) -{ - chunk_t blob; - - if (cred_encoding_args(args, CRED_PART_RSA_PUB_ASN1_DER, &blob, - CRED_PART_END)) - { - *encoding = asn1_wrap(ASN1_SEQUENCE, "mm", - asn1_algorithmIdentifier(OID_RSA_ENCRYPTION), - asn1_bitstring("c", blob, 0)); - return TRUE; - } - return FALSE; -} - -/** - * Build the fingerprint of the subjectPublicKeyInfo object. - */ -static bool build_info_sha1(chunk_t *encoding, va_list args) -{ - chunk_t pubkey; - - if (build_pub_info(&pubkey, args)) - { - return hash_pubkey(pubkey, encoding); - } - return FALSE; -} - -/** - * Build the fingerprint of the subjectPublicKey object. - */ -static bool build_sha1(chunk_t *encoding, va_list args) -{ - chunk_t blob; - - if (cred_encoding_args(args, CRED_PART_RSA_PUB_ASN1_DER, &blob, - CRED_PART_END)) - { - return hash_pubkey(chunk_clone(blob), encoding); - } - return FALSE; -} - -/** - * See header. - */ -bool tkm_encoder_encode(cred_encoding_type_t type, chunk_t *encoding, - va_list args) -{ - switch (type) - { - case KEYID_PUBKEY_INFO_SHA1: - return build_info_sha1(encoding, args); - case KEYID_PUBKEY_SHA1: - return build_sha1(encoding, args); - default: - return FALSE; - } -} diff --git a/src/charon-tkm/tests/tests.c b/src/charon-tkm/tests/tests.c index 669f4d500..ac152b690 100644 --- a/src/charon-tkm/tests/tests.c +++ b/src/charon-tkm/tests/tests.c @@ -36,8 +36,8 @@ static test_configuration_t tests[] = { #define TEST_SUITE(x) \ { .suite = x, }, -#define TEST_SUITE_DEPEND(x, type, args) \ - { .suite = x, .feature = PLUGIN_DEPENDS(type, args) }, +#define TEST_SUITE_DEPEND(x, type, ...) \ + { .suite = x, .feature = PLUGIN_DEPENDS(type, __VA_ARGS__) }, #include "tests.h" { .suite = NULL, } }; |