use hash size constants from hasher.h

This commit is contained in:
Andreas Steffen 2009-05-07 10:10:42 +02:00
parent 38a7792d8a
commit c08ae816a2
5 changed files with 16 additions and 26 deletions

View File

@ -1364,6 +1364,6 @@ void init_constants(void)
happy(initsubnet(&ipv6_any, 0, '0', &ipv6_all));
}
u_char secret_of_the_day[SHA1_DIGEST_SIZE];
u_char secret_of_the_day[HASH_SIZE_SHA1];

View File

@ -18,6 +18,7 @@
#define _CONSTANTS_H
#include <utils.h>
#include <crypto/hashers/hasher.h>
extern const char compile_time_interop_options[];
@ -278,32 +279,16 @@ extern const char sparse_end[];
#define COOKIE_SIZE 8
#define MAX_ISAKMP_SPI_SIZE 16
#define MD2_DIGEST_SIZE (128 / BITS_PER_BYTE)
#define MD5_DIGEST_SIZE (128 / BITS_PER_BYTE)
#define SHA1_DIGEST_SIZE (160 / BITS_PER_BYTE)
#define SHA2_256_DIGEST_SIZE (256 / BITS_PER_BYTE)
#define SHA2_384_DIGEST_SIZE (384 / BITS_PER_BYTE)
#define SHA2_512_DIGEST_SIZE (512 / BITS_PER_BYTE)
#define MD5_BLOCK_SIZE (512 / BITS_PER_BYTE)
#define SHA1_BLOCK_SIZE (512 / BITS_PER_BYTE)
#define SHA2_256_BLOCK_SIZE (512 / BITS_PER_BYTE)
#define SHA2_384_BLOCK_SIZE (1024 / BITS_PER_BYTE)
#define SHA2_512_BLOCK_SIZE (1024 / BITS_PER_BYTE)
#define DES_CBC_BLOCK_SIZE (64 / BITS_PER_BYTE)
#define DSS_QBITS 160 /* bits in DSS's "q" (FIPS 186-1) */
/* Maximum is required for SHA2_512 */
#define MAX_DIGEST_LEN SHA2_512_DIGEST_SIZE
#define MAX_HASH_BLOCK_SIZE SHA2_512_BLOCK_SIZE
#define MAX_DIGEST_LEN HASH_SIZE_SHA512
/* RFC 2404 "HMAC-SHA-1-96" section 3 */
#define HMAC_SHA1_KEY_LEN SHA1_DIGEST_SIZE
#define HMAC_SHA1_KEY_LEN HASH_SIZE_SHA1
/* RFC 2403 "HMAC-MD5-96" section 3 */
#define HMAC_MD5_KEY_LEN MD5_DIGEST_SIZE
#define HMAC_MD5_KEY_LEN HASH_SIZE_MD5
#define IKE_UDP_PORT 500
@ -1269,6 +1254,6 @@ enum dns_auth_level {
extern const char *const natt_type_bitnames[];
/* secret value for responder cookies */
extern u_char secret_of_the_day[SHA1_DIGEST_SIZE];
extern u_char secret_of_the_day[HASH_SIZE_SHA1];
#endif /* _CONSTANTS_H */

View File

@ -29,6 +29,7 @@
#include <asn1/asn1_parser.h>
#include <asn1/oid.h>
#include <crypto/rngs/rng.h>
#include <crypto/hashers/hasher.h>
#include "constants.h"
#include "defs.h"
@ -293,7 +294,7 @@ static const asn1Object_t singleResponseObjects[] = {
*/
static bool build_ocsp_location(const x509cert_t *cert, ocsp_location_t *location)
{
static u_char digest[SHA1_DIGEST_SIZE]; /* temporary storage */
static u_char digest[HASH_SIZE_SHA1]; /* temporary storage */
location->uri = cert->accessLocation;
@ -311,7 +312,7 @@ static bool build_ocsp_location(const x509cert_t *cert, ocsp_location_t *locatio
}
}
location->authNameID = chunk_create(digest, SHA1_DIGEST_SIZE);
location->authNameID = chunk_create(digest, HASH_SIZE_SHA1);
compute_digest(cert->issuer, OID_SHA1, &location->authNameID);
location->next = NULL;

View File

@ -15,11 +15,14 @@
#ifndef _PGP_H
#define _PGP_H
#include <crypto/hashers/hasher.h>
#include "pkcs1.h"
/*
* Length of PGP V3 fingerprint
*/
#define PGP_FINGERPRINT_SIZE MD5_DIGEST_SIZE
#define PGP_FINGERPRINT_SIZE HASH_SIZE_MD5
typedef char fingerprint_t[PGP_FINGERPRINT_SIZE];

View File

@ -30,6 +30,7 @@
#include <asn1/asn1_parser.h>
#include <asn1/oid.h>
#include <crypto/rngs/rng.h>
#include <crypto/hashers/hasher.h>
#include "../pluto/constants.h"
#include "../pluto/defs.h"
@ -267,7 +268,7 @@ end:
*/
void scep_generate_pkcs10_fingerprint(chunk_t pkcs10, chunk_t *fingerprint)
{
char buf[MD5_DIGEST_SIZE];
char buf[HASH_SIZE_MD5];
chunk_t digest = { buf, sizeof(buf) };
/* the fingerprint is the MD5 hash in hexadecimal format */
@ -284,7 +285,7 @@ void scep_generate_pkcs10_fingerprint(chunk_t pkcs10, chunk_t *fingerprint)
void scep_generate_transaction_id(const RSA_public_key_t *rsak,
chunk_t *transID, chunk_t *serialNumber)
{
char buf[MD5_DIGEST_SIZE];
char buf[HASH_SIZE_MD5];
chunk_t digest = { buf, sizeof(buf) };
chunk_t public_key = pkcs1_build_publicKeyInfo(rsak);