removed trailing spaces ([[:space:]]+$)
This commit is contained in:
@@ -130,14 +130,14 @@ struct builder_t {
|
||||
/**
|
||||
* Add a part to the construct.
|
||||
*
|
||||
* Any added parts are cloned/refcounted by the builder implementation, a
|
||||
* Any added parts are cloned/refcounted by the builder implementation, a
|
||||
* caller may need to free the passed ressources themself.
|
||||
*
|
||||
* @param part kind of part
|
||||
* @param ... part specific variable argument
|
||||
*/
|
||||
void (*add)(builder_t *this, builder_part_t part, ...);
|
||||
|
||||
|
||||
/**
|
||||
* Build the construct with all supplied parts.
|
||||
*
|
||||
|
||||
@@ -41,35 +41,35 @@ struct ac_t {
|
||||
* Implements the certificate_t interface
|
||||
*/
|
||||
certificate_t certificate;
|
||||
|
||||
|
||||
/**
|
||||
* Get the attribute certificate's serial number.
|
||||
*
|
||||
* @return chunk pointing to serialNumber
|
||||
*/
|
||||
chunk_t (*get_serial)(ac_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the serial number of the holder certificate.
|
||||
*
|
||||
* @return chunk pointing to serialNumber
|
||||
*/
|
||||
chunk_t (*get_holderSerial)(ac_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the issuer of the holder certificate.
|
||||
*
|
||||
* @return holderIssuer as identification_t*
|
||||
*/
|
||||
identification_t* (*get_holderIssuer)(ac_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the thauthorityKeyIdentifier.
|
||||
*
|
||||
* @return authKeyIdentifier as chunk_t, to internal data
|
||||
*/
|
||||
chunk_t (*get_authKeyIdentifier)(ac_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Checks if two attribute certificates belong to the same holder
|
||||
*
|
||||
|
||||
@@ -88,7 +88,7 @@ extern enum_name_t *cert_validation_names;
|
||||
/**
|
||||
* An abstract certificate.
|
||||
*
|
||||
* A certificate designs a subject-issuer relationship. It may have an
|
||||
* A certificate designs a subject-issuer relationship. It may have an
|
||||
* associated public key.
|
||||
*/
|
||||
struct certificate_t {
|
||||
@@ -106,7 +106,7 @@ struct certificate_t {
|
||||
* @return subject identity
|
||||
*/
|
||||
identification_t* (*get_subject)(certificate_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Check if certificate contains a subject ID.
|
||||
*
|
||||
@@ -117,14 +117,14 @@ struct certificate_t {
|
||||
* @return matching value of best match
|
||||
*/
|
||||
id_match_t (*has_subject)(certificate_t *this, identification_t *subject);
|
||||
|
||||
|
||||
/**
|
||||
* Get the issuer which signed this certificate.
|
||||
*
|
||||
* @return issuer identity
|
||||
*/
|
||||
identification_t* (*get_issuer)(certificate_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Check if certificate contains an issuer ID.
|
||||
*
|
||||
@@ -135,7 +135,7 @@ struct certificate_t {
|
||||
* @return matching value of best match
|
||||
*/
|
||||
id_match_t (*has_issuer)(certificate_t *this, identification_t *issuer);
|
||||
|
||||
|
||||
/**
|
||||
* Check if this certificate is issued and signed by a specific issuer.
|
||||
*
|
||||
@@ -143,14 +143,14 @@ struct certificate_t {
|
||||
* @return TRUE if certificate issued by issuer and trusted
|
||||
*/
|
||||
bool (*issued_by)(certificate_t *this, certificate_t *issuer);
|
||||
|
||||
|
||||
/**
|
||||
* Get the public key associated to this certificate.
|
||||
*
|
||||
* @return newly referenced public_key, NULL if none available
|
||||
*/
|
||||
public_key_t* (*get_public_key)(certificate_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Check the lifetime of the certificate.
|
||||
*
|
||||
@@ -161,21 +161,21 @@ struct certificate_t {
|
||||
*/
|
||||
bool (*get_validity)(certificate_t *this, time_t *when,
|
||||
time_t *not_before, time_t *not_after);
|
||||
|
||||
|
||||
/**
|
||||
* Is this newer than that?
|
||||
*
|
||||
* @return TRUE if newer, FALSE otherwise
|
||||
*/
|
||||
bool (*is_newer)(certificate_t *this, certificate_t *that);
|
||||
|
||||
|
||||
/**
|
||||
* Get the certificate in an encoded form.
|
||||
*
|
||||
* @return allocated chunk of encoded cert
|
||||
*/
|
||||
chunk_t (*get_encoding)(certificate_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Check if two certificates are equal.
|
||||
*
|
||||
@@ -183,14 +183,14 @@ struct certificate_t {
|
||||
* @return TRUE if certificates are equal
|
||||
*/
|
||||
bool (*equals)(certificate_t *this, certificate_t *other);
|
||||
|
||||
|
||||
/**
|
||||
* Get a new reference to the certificate.
|
||||
*
|
||||
* @return this, with an increased refcount
|
||||
* @return this, with an increased refcount
|
||||
*/
|
||||
certificate_t* (*get_ref)(certificate_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a certificate.
|
||||
*/
|
||||
|
||||
@@ -56,21 +56,21 @@ struct crl_t {
|
||||
* Implements (parts of) the certificate_t interface
|
||||
*/
|
||||
certificate_t certificate;
|
||||
|
||||
|
||||
/**
|
||||
* Get the CRL serial number.
|
||||
*
|
||||
* @return chunk pointing to internal crlNumber
|
||||
*/
|
||||
chunk_t (*get_serial)(crl_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the the authorityKeyIdentifier.
|
||||
*
|
||||
* @return authKeyIdentifier chunk, point to internal data
|
||||
*/
|
||||
chunk_t (*get_authKeyIdentifier)(crl_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Create an enumerator over all revoked certificates.
|
||||
*
|
||||
@@ -80,7 +80,7 @@ struct crl_t {
|
||||
* @return enumerator over revoked certificates.
|
||||
*/
|
||||
enumerator_t* (*create_enumerator)(crl_t *this);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /** CRL_H_ @}*/
|
||||
|
||||
@@ -28,7 +28,7 @@ typedef struct ocsp_response_t ocsp_response_t;
|
||||
typedef enum ocsp_status_t ocsp_status_t;
|
||||
|
||||
/**
|
||||
* OCSP response status
|
||||
* OCSP response status
|
||||
*/
|
||||
enum ocsp_status_t {
|
||||
OCSP_SUCCESSFUL = 0,
|
||||
@@ -53,7 +53,7 @@ struct ocsp_response_t {
|
||||
* Implements certificiate_t interface
|
||||
*/
|
||||
certificate_t certificate;
|
||||
|
||||
|
||||
/**
|
||||
* Check the status of a certificate by this OCSP response.
|
||||
*
|
||||
@@ -65,18 +65,18 @@ struct ocsp_response_t {
|
||||
* @param next_update exptected time of next revocation list
|
||||
* @return certificate revocation status
|
||||
*/
|
||||
cert_validation_t (*get_status)(ocsp_response_t *this,
|
||||
cert_validation_t (*get_status)(ocsp_response_t *this,
|
||||
x509_t *subject, x509_t *issuer,
|
||||
time_t *revocation_time,
|
||||
crl_reason_t *revocation_reason,
|
||||
time_t *this_update, time_t *next_update);
|
||||
|
||||
|
||||
/**
|
||||
* Create an enumerator over the contained certificates.
|
||||
*
|
||||
* @return enumerator over certificate_t*
|
||||
*/
|
||||
enumerator_t* (*create_cert_enumerator)(ocsp_response_t *this);
|
||||
enumerator_t* (*create_cert_enumerator)(ocsp_response_t *this);
|
||||
};
|
||||
|
||||
#endif /** OCSP_RESPONSE_H_ @}*/
|
||||
|
||||
@@ -58,42 +58,42 @@ struct x509_t {
|
||||
* Implements certificate_t.
|
||||
*/
|
||||
certificate_t interface;
|
||||
|
||||
|
||||
/**
|
||||
* Get the flags set for this certificate.
|
||||
*
|
||||
* @return set of flags
|
||||
*/
|
||||
x509_flag_t (*get_flags)(x509_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the certificate serial number.
|
||||
*
|
||||
* @return chunk pointing to internal serial number
|
||||
*/
|
||||
chunk_t (*get_serial)(x509_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the the authorityKeyIdentifier.
|
||||
*
|
||||
* @return authKeyIdentifier as chunk_t, internal data
|
||||
*/
|
||||
chunk_t (*get_authKeyIdentifier)(x509_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Create an enumerator over all subjectAltNames.
|
||||
*
|
||||
* @return enumerator over subjectAltNames as identification_t*
|
||||
*/
|
||||
enumerator_t* (*create_subjectAltName_enumerator)(x509_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Create an enumerator over all CRL URIs.
|
||||
*
|
||||
* @return enumerator over URIs as char*
|
||||
*/
|
||||
enumerator_t* (*create_crl_uri_enumerator)(x509_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Create an enumerator over all OCSP URIs.
|
||||
*
|
||||
|
||||
@@ -41,17 +41,17 @@ struct private_credential_factory_t {
|
||||
* public functions
|
||||
*/
|
||||
credential_factory_t public;
|
||||
|
||||
|
||||
/**
|
||||
* list with entry_t
|
||||
*/
|
||||
linked_list_t *constructors;
|
||||
|
||||
|
||||
/**
|
||||
* Thread specific recursiveness counter
|
||||
*/
|
||||
pthread_key_t recursive;
|
||||
|
||||
|
||||
/**
|
||||
* lock access to builders
|
||||
*/
|
||||
@@ -74,7 +74,7 @@ struct entry_t {
|
||||
static bool builder_filter(entry_t *data, entry_t **in, builder_t **out)
|
||||
{
|
||||
builder_t *builder;
|
||||
|
||||
|
||||
if (data->type == (*in)->type &&
|
||||
data->subtype == (*in)->subtype)
|
||||
{
|
||||
@@ -95,15 +95,15 @@ static enumerator_t* create_builder_enumerator(
|
||||
private_credential_factory_t *this, credential_type_t type, int subtype)
|
||||
{
|
||||
entry_t *data = malloc_thing(entry_t);
|
||||
|
||||
|
||||
data->type = type;
|
||||
data->subtype = subtype;
|
||||
|
||||
|
||||
this->lock->read_lock(this->lock);
|
||||
return enumerator_create_cleaner(
|
||||
enumerator_create_filter(
|
||||
this->constructors->create_enumerator(this->constructors),
|
||||
(void*)builder_filter, data, free),
|
||||
(void*)builder_filter, data, free),
|
||||
(void*)this->lock->unlock, this->lock);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ static void add_builder(private_credential_factory_t *this,
|
||||
builder_constructor_t constructor)
|
||||
{
|
||||
entry_t *entry = malloc_thing(entry_t);
|
||||
|
||||
|
||||
entry->type = type;
|
||||
entry->subtype = subtype;
|
||||
entry->constructor = constructor;
|
||||
@@ -132,7 +132,7 @@ static void remove_builder(private_credential_factory_t *this,
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
entry_t *entry;
|
||||
|
||||
|
||||
this->lock->write_lock(this->lock);
|
||||
enumerator = this->constructors->create_enumerator(this->constructors);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
@@ -160,10 +160,10 @@ static void* create(private_credential_factory_t *this, credential_type_t type,
|
||||
void* construct = NULL, *fn, *data;
|
||||
int failures = 0;
|
||||
uintptr_t level;
|
||||
|
||||
|
||||
level = (uintptr_t)pthread_getspecific(this->recursive);
|
||||
pthread_setspecific(this->recursive, (void*)level + 1);
|
||||
|
||||
|
||||
enumerator = create_builder_enumerator(this, type, subtype);
|
||||
while (enumerator->enumerate(enumerator, &builder))
|
||||
{
|
||||
@@ -231,7 +231,7 @@ static void* create(private_credential_factory_t *this, credential_type_t type,
|
||||
break;
|
||||
}
|
||||
va_end(args);
|
||||
|
||||
|
||||
construct = builder->build(builder);
|
||||
if (construct)
|
||||
{
|
||||
@@ -243,7 +243,7 @@ static void* create(private_credential_factory_t *this, credential_type_t type,
|
||||
if (!construct && !level)
|
||||
{
|
||||
enum_name_t *names = key_type_names;
|
||||
|
||||
|
||||
if (type == CRED_CERTIFICATE)
|
||||
{
|
||||
names = certificate_type_names;
|
||||
@@ -278,11 +278,11 @@ credential_factory_t *credential_factory_create()
|
||||
this->public.add_builder = (void(*)(credential_factory_t*,credential_type_t type, int subtype, builder_constructor_t constructor))add_builder;
|
||||
this->public.remove_builder = (void(*)(credential_factory_t*,builder_constructor_t constructor))remove_builder;
|
||||
this->public.destroy = (void(*)(credential_factory_t*))destroy;
|
||||
|
||||
|
||||
this->constructors = linked_list_create();
|
||||
pthread_key_create(&this->recursive, NULL);
|
||||
this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ extern enum_name_t *credential_type_names;
|
||||
* Manages credential construction functions and creates instances.
|
||||
*/
|
||||
struct credential_factory_t {
|
||||
|
||||
|
||||
/**
|
||||
* Create a credential using a list of builder_part_t's.
|
||||
*
|
||||
@@ -64,12 +64,12 @@ struct credential_factory_t {
|
||||
*/
|
||||
void* (*create)(credential_factory_t *this, credential_type_t type,
|
||||
int subtype, ...);
|
||||
|
||||
|
||||
/**
|
||||
* Create an enumerator for a builder type.
|
||||
*
|
||||
* The build() method has to be called on each enumerated builder to
|
||||
* cleanup associated ressources.
|
||||
* The build() method has to be called on each enumerated builder to
|
||||
* cleanup associated ressources.
|
||||
*
|
||||
* @param type type of credentials the builder creates
|
||||
* @param subtype type specific subtype, such as certificate_type_t
|
||||
@@ -77,7 +77,7 @@ struct credential_factory_t {
|
||||
*/
|
||||
enumerator_t* (*create_builder_enumerator)(credential_factory_t *this,
|
||||
credential_type_t type, int subtype);
|
||||
|
||||
|
||||
/**
|
||||
* Register a builder_t constructor function.
|
||||
*
|
||||
@@ -85,16 +85,16 @@ struct credential_factory_t {
|
||||
* @param constructor builder constructor function to register
|
||||
*/
|
||||
void (*add_builder)(credential_factory_t *this,
|
||||
credential_type_t type, int subtype,
|
||||
credential_type_t type, int subtype,
|
||||
builder_constructor_t constructor);
|
||||
/**
|
||||
* Unregister a builder_t constructor function.
|
||||
*
|
||||
* @param constructor constructor function to unregister.
|
||||
*/
|
||||
void (*remove_builder)(credential_factory_t *this,
|
||||
void (*remove_builder)(credential_factory_t *this,
|
||||
builder_constructor_t constructor);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a credential_factory instance.
|
||||
*/
|
||||
|
||||
@@ -27,22 +27,22 @@ typedef struct private_key_encoding_t private_key_encoding_t;
|
||||
* Private data of an key_encoding_t object.
|
||||
*/
|
||||
struct private_key_encoding_t {
|
||||
|
||||
|
||||
/**
|
||||
* Public key_encoding_t interface.
|
||||
*/
|
||||
key_encoding_t public;
|
||||
|
||||
|
||||
/**
|
||||
* cached encodings, a table for each encoding_type_t, containing chunk_t*
|
||||
*/
|
||||
hashtable_t *cache[KEY_ENCODING_MAX];
|
||||
|
||||
|
||||
/**
|
||||
* Registered encoding fuctions, key_encoder_t
|
||||
*/
|
||||
linked_list_t *encoders;
|
||||
|
||||
|
||||
/**
|
||||
* lock to access cache/encoders
|
||||
*/
|
||||
@@ -56,14 +56,14 @@ bool key_encoding_args(va_list args, ...)
|
||||
{
|
||||
va_list parts, copy;
|
||||
bool failed = FALSE;
|
||||
|
||||
|
||||
va_start(parts, args);
|
||||
|
||||
|
||||
while (!failed)
|
||||
{
|
||||
key_encoding_part_t current, target;
|
||||
chunk_t *out, data;
|
||||
|
||||
|
||||
/* get the part we are looking for */
|
||||
target = va_arg(parts, key_encoding_part_t);
|
||||
if (target == KEY_PART_END)
|
||||
@@ -71,7 +71,7 @@ bool key_encoding_args(va_list args, ...)
|
||||
break;
|
||||
}
|
||||
out = va_arg(parts, chunk_t*);
|
||||
|
||||
|
||||
va_copy(copy, args);
|
||||
while (!failed)
|
||||
{
|
||||
@@ -117,7 +117,7 @@ static bool get_cache(private_key_encoding_t *this, key_encoding_type_t type,
|
||||
void *cache, chunk_t *encoding)
|
||||
{
|
||||
chunk_t *chunk;
|
||||
|
||||
|
||||
if (type >= KEY_ENCODING_MAX || type < 0)
|
||||
{
|
||||
return FALSE;
|
||||
@@ -143,7 +143,7 @@ static bool encode(private_key_encoding_t *this, key_encoding_type_t type,
|
||||
key_encoder_t encode;
|
||||
bool success = FALSE;
|
||||
chunk_t *chunk;
|
||||
|
||||
|
||||
if (type >= KEY_ENCODING_MAX || type < 0)
|
||||
{
|
||||
return FALSE;
|
||||
@@ -192,7 +192,7 @@ static void cache(private_key_encoding_t *this, key_encoding_type_t type,
|
||||
void *cache, chunk_t encoding)
|
||||
{
|
||||
chunk_t *chunk;
|
||||
|
||||
|
||||
if (type >= KEY_ENCODING_MAX || type < 0)
|
||||
{
|
||||
return free(encoding.ptr);
|
||||
@@ -217,7 +217,7 @@ static void clear_cache(private_key_encoding_t *this, void *cache)
|
||||
{
|
||||
key_encoding_type_t type;
|
||||
chunk_t *chunk;
|
||||
|
||||
|
||||
this->lock->write_lock(this->lock);
|
||||
for (type = 0; type < KEY_ENCODING_MAX; type++)
|
||||
{
|
||||
@@ -257,7 +257,7 @@ static void remove_encoder(private_key_encoding_t *this, key_encoder_t encoder)
|
||||
static void destroy(private_key_encoding_t *this)
|
||||
{
|
||||
key_encoding_type_t type;
|
||||
|
||||
|
||||
for (type = 0; type < KEY_ENCODING_MAX; type++)
|
||||
{
|
||||
/* We explicitly do not free remaining encodings. All keys should
|
||||
@@ -278,7 +278,7 @@ key_encoding_t *key_encoding_create()
|
||||
{
|
||||
private_key_encoding_t *this = malloc_thing(private_key_encoding_t);
|
||||
key_encoding_type_t type;
|
||||
|
||||
|
||||
this->public.encode = (bool(*)(key_encoding_t*, key_encoding_type_t type, void *cache, chunk_t *encoding, ...))encode;
|
||||
this->public.get_cache = (bool(*)(key_encoding_t*, key_encoding_type_t type, void *cache, chunk_t *encoding))get_cache;
|
||||
this->public.cache = (void(*)(key_encoding_t*, key_encoding_type_t type, void *cache, chunk_t encoding))cache;
|
||||
@@ -286,14 +286,14 @@ key_encoding_t *key_encoding_create()
|
||||
this->public.add_encoder = (void(*)(key_encoding_t*, key_encoder_t encoder))add_encoder;
|
||||
this->public.remove_encoder = (void(*)(key_encoding_t*, key_encoder_t encoder))remove_encoder;
|
||||
this->public.destroy = (void(*)(key_encoding_t*))destroy;
|
||||
|
||||
|
||||
for (type = 0; type < KEY_ENCODING_MAX; type++)
|
||||
{
|
||||
this->cache[type] = hashtable_create(hash, equals, 8);
|
||||
}
|
||||
this->encoders = linked_list_create();
|
||||
this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT);
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ enum key_encoding_type_t {
|
||||
KEY_ID_PGPV3,
|
||||
/** PGPv4 fingerprint */
|
||||
KEY_ID_PGPV4,
|
||||
|
||||
|
||||
/** PKCS#1 and similar ASN.1 key encoding */
|
||||
KEY_PUB_ASN1_DER,
|
||||
KEY_PRIV_ASN1_DER,
|
||||
@@ -83,7 +83,7 @@ enum key_encoding_type_t {
|
||||
/** PGP key encoding */
|
||||
KEY_PUB_PGP,
|
||||
KEY_PRIV_PGP,
|
||||
|
||||
|
||||
KEY_ENCODING_MAX,
|
||||
};
|
||||
|
||||
@@ -115,7 +115,7 @@ enum key_encoding_part_t {
|
||||
KEY_PART_ECDSA_PUB_ASN1_DER,
|
||||
/** a DER encoded ECDSA private key */
|
||||
KEY_PART_ECDSA_PRIV_ASN1_DER,
|
||||
|
||||
|
||||
KEY_PART_END,
|
||||
};
|
||||
|
||||
@@ -141,14 +141,14 @@ struct key_encoding_t {
|
||||
*/
|
||||
bool (*encode)(key_encoding_t *this, key_encoding_type_t type, void *cache,
|
||||
chunk_t *encoding, ...);
|
||||
|
||||
|
||||
/**
|
||||
* Clear all cached encodings of a given cache key.
|
||||
*
|
||||
* @param cache key used in encode() for caching
|
||||
*/
|
||||
void (*clear_cache)(key_encoding_t *this, void *cache);
|
||||
|
||||
|
||||
/**
|
||||
* Check for a cached encoding.
|
||||
*
|
||||
@@ -159,7 +159,7 @@ struct key_encoding_t {
|
||||
*/
|
||||
bool (*get_cache)(key_encoding_t *this, key_encoding_type_t type,
|
||||
void *cache, chunk_t *encoding);
|
||||
|
||||
|
||||
/**
|
||||
* Cache a key encoding created externally.
|
||||
*
|
||||
@@ -172,21 +172,21 @@ struct key_encoding_t {
|
||||
*/
|
||||
void (*cache)(key_encoding_t *this, key_encoding_type_t type, void *cache,
|
||||
chunk_t encoding);
|
||||
|
||||
|
||||
/**
|
||||
* Register a key encoder function.
|
||||
*
|
||||
* @param encoder key encoder function to add
|
||||
*/
|
||||
void (*add_encoder)(key_encoding_t *this, key_encoder_t encoder);
|
||||
|
||||
|
||||
/**
|
||||
* Unregister a previously registered key encoder function.
|
||||
*
|
||||
* @param encoder key encoder function to remove
|
||||
*/
|
||||
void (*remove_encoder)(key_encoding_t *this, key_encoder_t encoder);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a key_encoding_t.
|
||||
*/
|
||||
|
||||
@@ -22,12 +22,12 @@ bool private_key_equals(private_key_t *this, private_key_t *other)
|
||||
{
|
||||
key_encoding_type_t type;
|
||||
chunk_t a, b;
|
||||
|
||||
|
||||
if (this == other)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
for (type = 0; type < KEY_ENCODING_MAX; type++)
|
||||
{
|
||||
if (this->get_fingerprint(this, type, &a) &&
|
||||
@@ -46,7 +46,7 @@ bool private_key_belongs_to(private_key_t *private, public_key_t *public)
|
||||
{
|
||||
key_encoding_type_t type;
|
||||
chunk_t a, b;
|
||||
|
||||
|
||||
for (type = 0; type < KEY_ENCODING_MAX; type++)
|
||||
{
|
||||
if (private->get_fingerprint(private, type, &a) &&
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup private_key private_key
|
||||
* @{ @ingroup keys
|
||||
@@ -29,14 +29,14 @@ typedef struct private_key_t private_key_t;
|
||||
* Abstract private key interface.
|
||||
*/
|
||||
struct private_key_t {
|
||||
|
||||
|
||||
/**
|
||||
* Get the key type.
|
||||
*
|
||||
* @return type of the key
|
||||
*/
|
||||
key_type_t (*get_type)(private_key_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Create a signature over a chunk of data.
|
||||
*
|
||||
@@ -45,7 +45,7 @@ struct private_key_t {
|
||||
* @param signature where to allocate created signature
|
||||
* @return TRUE if signature created
|
||||
*/
|
||||
bool (*sign)(private_key_t *this, signature_scheme_t scheme,
|
||||
bool (*sign)(private_key_t *this, signature_scheme_t scheme,
|
||||
chunk_t data, chunk_t *signature);
|
||||
/**
|
||||
* Decrypt a chunk of data.
|
||||
@@ -55,37 +55,37 @@ struct private_key_t {
|
||||
* @return TRUE if data decrypted and plaintext allocated
|
||||
*/
|
||||
bool (*decrypt)(private_key_t *this, chunk_t crypto, chunk_t *plain);
|
||||
|
||||
|
||||
/**
|
||||
* Get the strength of the key in bytes.
|
||||
*
|
||||
*
|
||||
* @return strength of the key in bytes
|
||||
*/
|
||||
size_t (*get_keysize) (private_key_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the public part from the private key.
|
||||
*
|
||||
* @return public key
|
||||
*/
|
||||
public_key_t* (*get_public_key)(private_key_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Check if two private keys are equal.
|
||||
*
|
||||
*
|
||||
* @param other other private key
|
||||
* @return TRUE, if equality
|
||||
*/
|
||||
bool (*equals) (private_key_t *this, private_key_t *other);
|
||||
|
||||
|
||||
/**
|
||||
* Check if a private key belongs to a public key.
|
||||
*
|
||||
*
|
||||
* @param public public key
|
||||
* @return TRUE, if keys belong together
|
||||
*/
|
||||
bool (*belongs_to) (private_key_t *this, public_key_t *public);
|
||||
|
||||
|
||||
/**
|
||||
* Get the fingerprint of the key.
|
||||
*
|
||||
@@ -95,7 +95,7 @@ struct private_key_t {
|
||||
*/
|
||||
bool (*get_fingerprint)(private_key_t *this, key_encoding_type_t type,
|
||||
chunk_t *fp);
|
||||
|
||||
|
||||
/**
|
||||
* Get the key in an encoded form as a chunk.
|
||||
*
|
||||
@@ -105,14 +105,14 @@ struct private_key_t {
|
||||
*/
|
||||
bool (*get_encoding)(private_key_t *this, key_encoding_type_t type,
|
||||
chunk_t *encoding);
|
||||
|
||||
|
||||
/**
|
||||
* Increase the refcount to this private key.
|
||||
*
|
||||
* @return this, with an increased refcount
|
||||
*/
|
||||
private_key_t* (*get_ref)(private_key_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Decrease refcount, destroy private_key if no more references.
|
||||
*/
|
||||
|
||||
@@ -49,12 +49,12 @@ bool public_key_equals(public_key_t *this, public_key_t *other)
|
||||
{
|
||||
key_encoding_type_t type;
|
||||
chunk_t a, b;
|
||||
|
||||
|
||||
if (this == other)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
for (type = 0; type < KEY_ENCODING_MAX; type++)
|
||||
{
|
||||
if (this->get_fingerprint(this, type, &a) &&
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup public_key public_key
|
||||
* @{ @ingroup keys
|
||||
@@ -53,7 +53,7 @@ extern enum_name_t *key_type_names;
|
||||
* Signature scheme for signature creation
|
||||
*
|
||||
* EMSA-PKCS1 signatures are defined in PKCS#1 standard.
|
||||
* A prepended ASN.1 encoded digestInfo field contains the
|
||||
* A prepended ASN.1 encoded digestInfo field contains the
|
||||
* OID of the used hash algorithm.
|
||||
*/
|
||||
enum signature_scheme_t {
|
||||
@@ -107,7 +107,7 @@ struct public_key_t {
|
||||
* @return type of the key
|
||||
*/
|
||||
key_type_t (*get_type)(public_key_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Verifies a signature against a chunk of data.
|
||||
*
|
||||
@@ -116,9 +116,9 @@ struct public_key_t {
|
||||
* @param signature signature to check
|
||||
* @return TRUE if signature matches
|
||||
*/
|
||||
bool (*verify)(public_key_t *this, signature_scheme_t scheme,
|
||||
bool (*verify)(public_key_t *this, signature_scheme_t scheme,
|
||||
chunk_t data, chunk_t signature);
|
||||
|
||||
|
||||
/**
|
||||
* Encrypt a chunk of data.
|
||||
*
|
||||
@@ -127,10 +127,10 @@ struct public_key_t {
|
||||
* @return TRUE if data successfully encrypted
|
||||
*/
|
||||
bool (*encrypt)(public_key_t *this, chunk_t plain, chunk_t *crypto);
|
||||
|
||||
|
||||
/**
|
||||
* Check if two public keys are equal.
|
||||
*
|
||||
*
|
||||
* @param other other public key
|
||||
* @return TRUE, if equality
|
||||
*/
|
||||
@@ -138,11 +138,11 @@ struct public_key_t {
|
||||
|
||||
/**
|
||||
* Get the strength of the key in bytes.
|
||||
*
|
||||
*
|
||||
* @return strength of the key in bytes
|
||||
*/
|
||||
size_t (*get_keysize) (public_key_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the fingerprint of the key.
|
||||
*
|
||||
@@ -152,7 +152,7 @@ struct public_key_t {
|
||||
*/
|
||||
bool (*get_fingerprint)(public_key_t *this, key_encoding_type_t type,
|
||||
chunk_t *fp);
|
||||
|
||||
|
||||
/**
|
||||
* Get the key in an encoded form as a chunk.
|
||||
*
|
||||
@@ -162,14 +162,14 @@ struct public_key_t {
|
||||
*/
|
||||
bool (*get_encoding)(public_key_t *this, key_encoding_type_t type,
|
||||
chunk_t *encoding);
|
||||
|
||||
|
||||
/**
|
||||
* Increase the refcount of the key.
|
||||
*
|
||||
* @return this with an increased refcount
|
||||
*/
|
||||
public_key_t* (*get_ref)(public_key_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a public_key instance.
|
||||
*/
|
||||
@@ -187,7 +187,7 @@ bool public_key_equals(public_key_t *this, public_key_t *other);
|
||||
|
||||
/**
|
||||
* Conversion of ASN.1 signature or hash OID to signature scheme.
|
||||
*
|
||||
*
|
||||
* @param oid ASN.1 OID
|
||||
* @return signature_scheme, SIGN_UNKNOWN if OID is unsupported
|
||||
*/
|
||||
|
||||
@@ -34,17 +34,17 @@ struct private_shared_key_t {
|
||||
* public functions
|
||||
*/
|
||||
shared_key_t public;
|
||||
|
||||
|
||||
/**
|
||||
* type of this shared key
|
||||
*/
|
||||
shared_key_type_t type;
|
||||
|
||||
|
||||
/**
|
||||
* associated shared key data
|
||||
*/
|
||||
chunk_t key;
|
||||
|
||||
|
||||
/**
|
||||
* reference counter
|
||||
*/
|
||||
@@ -94,16 +94,16 @@ 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;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,28 +55,28 @@ extern enum_name_t *shared_key_type_names;
|
||||
* reading.
|
||||
*/
|
||||
struct shared_key_t {
|
||||
|
||||
|
||||
/**
|
||||
* Get the kind of this key.
|
||||
*
|
||||
* @return type of the key
|
||||
*/
|
||||
shared_key_type_t (*get_type)(shared_key_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get the shared key data.
|
||||
*
|
||||
* @return chunk pointing to the internal key
|
||||
*/
|
||||
chunk_t (*get_key)(shared_key_t *this);
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Increase refcount of the key.
|
||||
*
|
||||
* @return this with an increased refcount
|
||||
* @return this with an increased refcount
|
||||
*/
|
||||
shared_key_t* (*get_ref)(shared_key_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a shared_key instance if all references are gone.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user