Commit f9e5d1c8 authored by Brian Wellington's avatar Brian Wellington
Browse files

Added a routine to compute the length of a generated shared secret

parent 688d43f2
......@@ -17,7 +17,7 @@
/*
* Principal Author: Brian Wellington
* $Id: dst_api.c,v 1.11 1999/09/27 16:55:44 bwelling Exp $
* $Id: dst_api.c,v 1.12 1999/10/05 15:08:52 bwelling Exp $
*/
#include <config.h>
......@@ -686,6 +686,35 @@ dst_sig_size(const dst_key_t *key) {
case DST_ALG_HMACSHA1:
return (20);
case DST_ALG_DH:
return (-1);
default:
REQUIRE(ISC_FALSE);
return (-1);
}
}
/*
* dst_secret_size
* Computes the maximum size of a shared secret generated by the given key
* Parameters
* key The DST key
* Returns
* n The number of bytes necessary to hold the shared secret
*/
int
dst_secret_size(const dst_key_t *key) {
RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
REQUIRE(VALID_KEY(key));
REQUIRE(dst_supported_algorithm(key->key_alg) == ISC_TRUE);
switch (key->key_alg) {
case DST_ALG_RSA:
case DST_ALG_DSA:
case DST_ALG_HMACMD5:
case DST_ALG_HMACSHA1:
return (-1);
case DST_ALG_DH:
return (key->key_size + 7) / 8;
default:
REQUIRE(ISC_FALSE);
return (-1);
......
......@@ -271,10 +271,26 @@ dst_key_isprivate(const dst_key_t *key);
*
* Requires:
* "key" is a valid key.
*
* Returns:
* n The size of the signature
* -1 The key's algorithm does not support signatures
*/
int
dst_sig_size(const dst_key_t *key);
/* Computes the size of a shared secret generated by the given key.
*
* Requires:
* "key" is a valid key.
*
* Returns:
* n The size of the secret
* -1 The key's algorithm does not support shared secrets
*/
int
dst_secret_size(const dst_key_t *key);
/* Generate random data.
*
* Requires:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment