better split up of library files "types.h" & "definitions.h"

centralized all printf specifier character definitions
reuse of arginfo handlers
more cleanups
fixed more AMD64 issues
added DEBUG_LEVEL compile flag to exclude DBGn() statements
This commit is contained in:
Martin Willi
2006-10-31 12:27:59 +00:00
parent de8b8a8c44
commit db7ef62494
151 changed files with 1094 additions and 1061 deletions
+1 -2
View File
@@ -22,8 +22,7 @@
#include <time.h>
#include <types.h>
#include <definitions.h>
#include <library.h>
#include "certinfo.h"
+1 -2
View File
@@ -27,8 +27,7 @@ typedef enum cert_status_t cert_status_t;
typedef enum crl_reason_t crl_reason_t;
typedef struct certinfo_t certinfo_t;
#include <types.h>
#include <definitions.h>
#include <library.h>
/**
* RFC 2560 OCSP - certificate status
+7 -30
View File
@@ -25,9 +25,8 @@
#include <string.h>
#include <printf.h>
#include <types.h>
#include <library.h>
#include <definitions.h>
#include <debug.h>
#include <asn1/oid.h>
#include <asn1/asn1.h>
#include <asn1/pem.h>
@@ -219,7 +218,7 @@ bool parse_x509crl(chunk_t blob, u_int level0, private_crl_t *crl)
asn1_ctx_t ctx;
bool critical;
chunk_t extnID;
chunk_t userCertificate = CHUNK_INITIALIZER;
chunk_t userCertificate = chunk_empty;
revokedCert_t *revokedCert = NULL;
chunk_t object;
u_int level;
@@ -473,34 +472,12 @@ static int print(FILE *stream, const struct printf_info *info,
return written;
}
/**
* arginfo handler in printf()
*/
static int print_arginfo(const struct printf_info *info, size_t n, int *argtypes)
{
if (info->alt)
{
if (n > 1)
{
argtypes[0] = PA_POINTER;
argtypes[1] = PA_INT;
}
return 2;
}
if (n > 0)
{
argtypes[0] = PA_POINTER;
}
return 1;
}
/**
* register printf() handlers
*/
static void __attribute__ ((constructor))print_register()
{
register_printf_function(CRL_PRINTF_SPEC, print, print_arginfo);
register_printf_function(PRINTF_CRL, print, arginfo_ptr_alt_ptr_int);
}
/*
@@ -512,11 +489,11 @@ crl_t *crl_create_from_chunk(chunk_t chunk)
/* initialize */
this->crlDistributionPoints = linked_list_create();
this->tbsCertList = CHUNK_INITIALIZER;
this->tbsCertList = chunk_empty;
this->issuer = NULL;
this->revokedCertificates = linked_list_create();
this->authKeyID = CHUNK_INITIALIZER;
this->authKeySerialNumber = CHUNK_INITIALIZER;
this->authKeyID = chunk_empty;
this->authKeySerialNumber = chunk_empty;
/* public functions */
this->public.get_issuer = (identification_t* (*) (const crl_t*))get_issuer;
@@ -543,7 +520,7 @@ crl_t *crl_create_from_chunk(chunk_t chunk)
crl_t *crl_create_from_file(const char *filename)
{
bool pgp = FALSE;
chunk_t chunk = CHUNK_INITIALIZER;
chunk_t chunk = chunk_empty;
crl_t *crl = NULL;
if (!pem_asn1_load_file(filename, NULL, "crl", &chunk, &pgp))
+1 -9
View File
@@ -25,20 +25,12 @@
typedef struct crl_t crl_t;
#include <types.h>
#include <definitions.h>
#include <library.h>
#include <crypto/rsa/rsa_public_key.h>
#include <crypto/certinfo.h>
#include <utils/identification.h>
#include <utils/iterator.h>
/**
* printf specifier for printing crls. When using the
* #-modifier, an additional bool argument defines if dates
* are printed in UTC.
*/
#define CRL_PRINTF_SPEC 'U'
/**
* @brief X.509 certificate revocation list
*
+1 -1
View File
@@ -27,7 +27,7 @@
typedef enum encryption_algorithm_t encryption_algorithm_t;
typedef struct crypter_t crypter_t;
#include <types.h>
#include <library.h>
/**
* @brief Encryption algorithm, as in IKEv2 RFC 3.3.2.
+1 -1
View File
@@ -27,7 +27,7 @@
typedef enum diffie_hellman_group_t diffie_hellman_group_t;
typedef struct diffie_hellman_t diffie_hellman_t;
#include <types.h>
#include <library.h>
/**
* @brief Diffie-Hellman group.
+1 -1
View File
@@ -27,7 +27,7 @@
typedef enum hash_algorithm_t hash_algorithm_t;
typedef struct hasher_t hasher_t;
#include <types.h>
#include <library.h>
/**
* @brief Algorithms to use for hashing.
@@ -30,8 +30,6 @@
#include "md5_hasher.h"
#include <definitions.h>
/* Constants for MD5Transform routine. */
#define S11 7
@@ -28,8 +28,6 @@
#include "sha1_hasher.h"
#include <definitions.h>
/*
* ugly macro stuff
*/
@@ -27,8 +27,6 @@
#include "sha2_hasher.h"
#include <definitions.h>
typedef struct private_sha512_hasher_t private_sha512_hasher_t;
-1
View File
@@ -26,7 +26,6 @@
typedef struct hmac_t hmac_t;
#include <crypto/hashers/hasher.h>
#include <definitions.h>
/**
* @brief Message authentication using hash functions.
-2
View File
@@ -25,8 +25,6 @@
#include "prf_plus.h"
#include <definitions.h>
typedef struct private_prf_plus_t private_prf_plus_t;
/**
+1 -1
View File
@@ -26,7 +26,7 @@
typedef struct hmac_prf_t hmac_prf_t;
#include <types.h>
#include <library.h>
#include <crypto/prfs/prf.h>
#include <crypto/hashers/hasher.h>
+1 -1
View File
@@ -27,7 +27,7 @@
typedef enum pseudo_random_function_t pseudo_random_function_t;
typedef struct prf_t prf_t;
#include <types.h>
#include <library.h>
/**
* @brief Pseudo random function, as in IKEv2 RFC 3.3.2.
@@ -762,7 +762,7 @@ rsa_private_key_t *rsa_private_key_create_from_chunk(chunk_t blob)
rsa_private_key_t *rsa_private_key_create_from_file(char *filename, chunk_t *passphrase)
{
bool pgp = FALSE;
chunk_t chunk = CHUNK_INITIALIZER;
chunk_t chunk = chunk_empty;
rsa_private_key_t *key = NULL;
if (!pem_asn1_load_file(filename, passphrase, "private key", &chunk, &pgp))
@@ -26,8 +26,7 @@
typedef struct rsa_private_key_t rsa_private_key_t;
#include <types.h>
#include <definitions.h>
#include <library.h>
#include <crypto/rsa/rsa_public_key.h>
#include <crypto/hashers/hasher.h>
@@ -485,7 +485,7 @@ rsa_public_key_t *rsa_public_key_create_from_chunk(chunk_t blob)
rsa_public_key_t *rsa_public_key_create_from_file(char *filename)
{
bool pgp = FALSE;
chunk_t chunk = CHUNK_INITIALIZER;
chunk_t chunk = chunk_empty;
rsa_public_key_t *pubkey = NULL;
if (!pem_asn1_load_file(filename, NULL, "public key", &chunk, &pgp))
@@ -28,8 +28,7 @@ typedef struct rsa_public_key_t rsa_public_key_t;
#include <gmp.h>
#include <types.h>
#include <definitions.h>
#include <library.h>
/**
* @brief RSA public key with associated functions.
+1 -2
View File
@@ -27,8 +27,7 @@
typedef enum integrity_algorithm_t integrity_algorithm_t;
typedef struct signer_t signer_t;
#include <types.h>
#include <definitions.h>
#include <library.h>
/**
* @brief Integrity algorithm, as in IKEv2 RFC 3.3.2.
+7 -30
View File
@@ -28,9 +28,8 @@
#include "x509.h"
#include <types.h>
#include <library.h>
#include <definitions.h>
#include <debug.h>
#include <asn1/oid.h>
#include <asn1/asn1.h>
#include <asn1/pem.h>
@@ -1161,34 +1160,12 @@ static int print(FILE *stream, const struct printf_info *info,
return written;
}
/**
* arginfo handler in printf()
*/
static int print_arginfo(const struct printf_info *info, size_t n, int *argtypes)
{
if (info->alt)
{
if (n > 1)
{
argtypes[0] = PA_POINTER;
argtypes[1] = PA_INT;
}
return 2;
}
if (n > 0)
{
argtypes[0] = PA_POINTER;
}
return 1;
}
/**
* register printf() handlers
*/
static void __attribute__ ((constructor))print_register()
{
register_printf_function(X509_PRINTF_SPEC, print, print_arginfo);
register_printf_function(PRINTF_X509, print, arginfo_ptr_alt_ptr_int);
}
/**
@@ -1215,15 +1192,15 @@ x509_t *x509_create_from_chunk(chunk_t chunk)
private_x509_t *this = malloc_thing(private_x509_t);
/* initialize */
this->subjectPublicKey = CHUNK_INITIALIZER;
this->subjectPublicKey = chunk_empty;
this->public_key = NULL;
this->subject = NULL;
this->issuer = NULL;
this->subjectAltNames = linked_list_create();
this->crlDistributionPoints = linked_list_create();
this->subjectKeyID = CHUNK_INITIALIZER;
this->authKeyID = CHUNK_INITIALIZER;
this->authKeySerialNumber = CHUNK_INITIALIZER;
this->subjectKeyID = chunk_empty;
this->authKeyID = chunk_empty;
this->authKeySerialNumber = chunk_empty;
/* public functions */
this->public.equals = (bool (*) (const x509_t*,const x509_t*))equals;
@@ -1270,7 +1247,7 @@ x509_t *x509_create_from_chunk(chunk_t chunk)
x509_t *x509_create_from_file(const char *filename, const char *label)
{
bool pgp = FALSE;
chunk_t chunk = CHUNK_INITIALIZER;
chunk_t chunk = chunk_empty;
x509_t *cert = NULL;
if (!pem_asn1_load_file(filename, NULL, label, &chunk, &pgp))
+1 -9
View File
@@ -25,20 +25,12 @@
typedef struct x509_t x509_t;
#include <types.h>
#include <definitions.h>
#include <library.h>
#include <crypto/rsa/rsa_public_key.h>
#include <crypto/certinfo.h>
#include <utils/identification.h>
#include <utils/iterator.h>
/**
* printf specifier for printing certificates. When using the
* #-modifier, an additional bool argument defines if dates
* are printed in UTC.
*/
#define X509_PRINTF_SPEC 'Q'
/**
* @brief X.509 certificate.
*