diff options
author | Yves-Alexis Perez <corsac@corsac.net> | 2012-06-28 21:16:07 +0200 |
---|---|---|
committer | Yves-Alexis Perez <corsac@corsac.net> | 2012-06-28 21:16:07 +0200 |
commit | b34738ed08c2227300d554b139e2495ca5da97d6 (patch) | |
tree | 62f33b52820f2e49f0e53c0f8c636312037c8054 /src/libstrongswan/credentials/keys | |
parent | 0a9d51a49042a68daa15b0c74a2b7f152f52606b (diff) | |
download | vyos-strongswan-b34738ed08c2227300d554b139e2495ca5da97d6.tar.gz vyos-strongswan-b34738ed08c2227300d554b139e2495ca5da97d6.zip |
Imported Upstream version 4.6.4
Diffstat (limited to 'src/libstrongswan/credentials/keys')
-rw-r--r-- | src/libstrongswan/credentials/keys/private_key.h | 10 | ||||
-rw-r--r-- | src/libstrongswan/credentials/keys/public_key.c | 3 | ||||
-rw-r--r-- | src/libstrongswan/credentials/keys/public_key.h | 12 | ||||
-rw-r--r-- | src/libstrongswan/credentials/keys/shared_key.c | 47 |
4 files changed, 34 insertions, 38 deletions
diff --git a/src/libstrongswan/credentials/keys/private_key.h b/src/libstrongswan/credentials/keys/private_key.h index e57d3f5a5..b9f7dad55 100644 --- a/src/libstrongswan/credentials/keys/private_key.h +++ b/src/libstrongswan/credentials/keys/private_key.h @@ -133,11 +133,11 @@ struct private_key_t { /** * Generic private key equals() implementation, usable by implementors. * - * @param this first key to compare - * @param other second key to compare + * @param private private key to check + * @param other key to compare * @return TRUE if this is equal to other */ -bool private_key_equals(private_key_t *this, private_key_t *other); +bool private_key_equals(private_key_t *private, private_key_t *other); /** * Generic private key belongs_to() implementation, usable by implementors. @@ -151,10 +151,10 @@ bool private_key_belongs_to(private_key_t *private, public_key_t *public); /** * Generic private key has_fingerprint() implementation, usable by implementors. * - * @param this key to check fingerprint + * @param private private key to check * @param fingerprint fingerprint to check * @return TRUE if key has given fingerprint */ -bool private_key_has_fingerprint(private_key_t *this, chunk_t fingerprint); +bool private_key_has_fingerprint(private_key_t *private, chunk_t fingerprint); #endif /** PRIVATE_KEY_H_ @}*/ diff --git a/src/libstrongswan/credentials/keys/public_key.c b/src/libstrongswan/credentials/keys/public_key.c index 22df5dd1b..37bba77d1 100644 --- a/src/libstrongswan/credentials/keys/public_key.c +++ b/src/libstrongswan/credentials/keys/public_key.c @@ -17,7 +17,8 @@ #include "public_key.h" -ENUM(key_type_names, KEY_RSA, KEY_DSA, +ENUM(key_type_names, KEY_ANY, KEY_DSA, + "ANY", "RSA", "ECDSA", "DSA" diff --git a/src/libstrongswan/credentials/keys/public_key.h b/src/libstrongswan/credentials/keys/public_key.h index d20d2736b..fdbe17f2c 100644 --- a/src/libstrongswan/credentials/keys/public_key.h +++ b/src/libstrongswan/credentials/keys/public_key.h @@ -151,7 +151,7 @@ struct public_key_t { * @param scheme encryption scheme to use * @param plain chunk containing plaintext data * @param crypto where to allocate encrypted data - * @return TRUE if data successfully encrypted + * @return TRUE if data successfully encrypted */ bool (*encrypt)(public_key_t *this, encryption_scheme_t scheme, chunk_t plain, chunk_t *crypto); @@ -215,20 +215,20 @@ struct public_key_t { /** * Generic public key equals() implementation, usable by implementors. * - * @param this first key to compare - * @param other second key to compare + * @param public public key to check + * @param other key to compare * @return TRUE if this is equal to other */ -bool public_key_equals(public_key_t *this, public_key_t *other); +bool public_key_equals(public_key_t *public, public_key_t *other); /** * Generic public key has_fingerprint() implementation, usable by implementors. * - * @param this key to check fingerprint + * @param public public key to check * @param fingerprint fingerprint to check * @return TRUE if key has given fingerprint */ -bool public_key_has_fingerprint(public_key_t *this, chunk_t fingerprint); +bool public_key_has_fingerprint(public_key_t *public, chunk_t fingerprint); /** * Conversion of ASN.1 signature or hash OID to signature scheme. diff --git a/src/libstrongswan/credentials/keys/shared_key.c b/src/libstrongswan/credentials/keys/shared_key.c index f695c078d..1c2d31167 100644 --- a/src/libstrongswan/credentials/keys/shared_key.c +++ b/src/libstrongswan/credentials/keys/shared_key.c @@ -51,35 +51,27 @@ struct private_shared_key_t { refcount_t ref; }; -/** - * Implements shared_key_t.get_type - */ -static shared_key_type_t get_type(private_shared_key_t *this) +METHOD(shared_key_t, get_type, shared_key_type_t, + private_shared_key_t *this) { return this->type; } -/** - * Implements shared_key_t.get_key - */ -static chunk_t get_key(private_shared_key_t *this) +METHOD(shared_key_t, get_key, chunk_t, + private_shared_key_t *this) { return this->key; } -/** - * Implements shared_key_t.get_ref - */ -static shared_key_t* get_ref(private_shared_key_t *this) +METHOD(shared_key_t, get_ref, shared_key_t*, + private_shared_key_t *this) { ref_get(&this->ref); return &this->public; } -/** - * Implementation of shared_key_t.destroy - */ -static void destroy(private_shared_key_t *this) +METHOD(shared_key_t, destroy, void, + private_shared_key_t *this) { if (ref_put(&this->ref)) { @@ -93,16 +85,19 @@ static void destroy(private_shared_key_t *this) */ shared_key_t *shared_key_create(shared_key_type_t type, chunk_t key) { - private_shared_key_t *this = malloc_thing(private_shared_key_t); - - this->public.get_type = (shared_key_type_t (*)(shared_key_t *this))get_type; - this->public.get_key = (chunk_t (*)(shared_key_t *this))get_key; - this->public.get_ref = (shared_key_t* (*)(shared_key_t *this))get_ref; - this->public.destroy = (void(*)(shared_key_t*))destroy; - - this->type = type; - this->key = key; - this->ref = 1; + private_shared_key_t *this; + + INIT(this, + .public = { + .get_type = _get_type, + .get_key = _get_key, + .get_ref = _get_ref, + .destroy = _destroy, + }, + .type = type, + .key = key, + .ref = 1, + ); return &this->public; } |