*/
static int
encode_ber_digest_info (gnutls_digest_algorithm_t hash,
- const gnutls_datum_t * digest, gnutls_datum_t * info)
+ const gnutls_datum_t * digest, gnutls_datum_t * output)
{
ASN1_TYPE dinfo = ASN1_TYPE_EMPTY;
int result;
return _gnutls_asn2err (result);
}
- info->size = 0;
- asn1_der_coding (dinfo, "", NULL, &info->size, NULL);
+ output->size = 0;
+ asn1_der_coding (dinfo, "", NULL, &output->size, NULL);
- info->data = gnutls_malloc (info->size);
- if (info->data == NULL)
+ output->data = gnutls_malloc (output->size);
+ if (output->data == NULL)
{
gnutls_assert ();
asn1_delete_structure (&dinfo);
return GNUTLS_E_MEMORY_ERROR;
}
- result = asn1_der_coding (dinfo, "", info->data, &info->size, NULL);
+ result = asn1_der_coding (dinfo, "", output->data, &output->size, NULL);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
pk_dsa_hash (const gnutls_datum_t * text, gnutls_datum_t * hash)
{
int ret;
- opaque _digest[MAX_HASH_SIZE];
digest_hd_st hd;
gnutls_datum_t digest;
+ opaque _digest[MAX_HASH_SIZE];
gnutls_digest_algorithm_t hash = _gnutls_dsa_q_to_hash(params[1]);
+ hash->size = _gnutls_hash_get_algo_len(hash);
+ hash->data = gnutls_malloc( hash->size);
+ if (hash->data == NULL)
+ {
+ gnutls_assert();
+ return GNUTLS_E_MEMORY_ERROR;
+ }
+
ret = _gnutls_hash_init (&hd, hash);
+
if (ret < 0)
{
gnutls_assert ();
- return ret;
+ goto fail;
}
_gnutls_hash (&hd, text->data, text->size);
- _gnutls_hash_deinit (&hd, _digest);
- digest.data = _digest;
- digest.size = _gnutls_hash_get_algo_len(hash);
-
- if ((ret =
- _gnutls_sign (GNUTLS_PK_DSA, params, params_len, &digest,
- signature)) < 0)
- {
- gnutls_assert ();
- return ret;
- }
+ _gnutls_hash_deinit (&hd, hash->data);
return 0;
+
+fail:
+ gnutls_free(hash->data);
+
+ return ret;
}
/* This is the same as the _gnutls_x509_sign, but this one will decode