gnutls_mac_output_func output;
gnutls_mac_deinit_func deinit;
gnutls_mac_fast_func fast;
+ gnutls_mac_copy_func copy;
/* Not needed for registered on run-time. Only included
* should define it. */
mac->setnonce = cc->setnonce;
mac->output = cc->output;
mac->deinit = cc->deinit;
+ mac->copy = cc->copy;
return 0;
}
mac->setnonce = _gnutls_mac_ops.setnonce;
mac->output = _gnutls_mac_ops.output;
mac->deinit = _gnutls_mac_ops.deinit;
+ mac->copy = _gnutls_mac_ops.copy;
if (_gnutls_mac_ops.setkey(mac->handle, key, keylen) < 0) {
gnutls_assert();
return 0;
}
+int _gnutls_mac_copy(const mac_hd_st * handle, mac_hd_st * dst)
+{
+ if (handle->copy == NULL)
+ return gnutls_assert_val(GNUTLS_E_HASH_FAILED);
+
+ *dst = *handle; /* copy data */
+ dst->handle = handle->copy(handle->handle);
+
+ if (dst->handle == NULL)
+ return GNUTLS_E_HASH_FAILED;
+
+ return 0;
+}
+
void _gnutls_mac_deinit(mac_hd_st * handle, void *digest)
{
if (handle->handle == NULL) {
typedef int (*output_func) (void *src_ctx, void *digest,
size_t digestsize);
typedef void (*hash_deinit_func) (void *handle);
+typedef void *(*copy_func) (const void *handle);
typedef struct {
const mac_entry_st *e;
nonce_func setnonce;
output_func output;
hash_deinit_func deinit;
+ copy_func copy;
void *handle;
} mac_hd_st;
int _gnutls_mac_init(mac_hd_st *, const mac_entry_st * e,
const void *key, int keylen);
+int _gnutls_mac_copy(const mac_hd_st * handle, mac_hd_st * dst);
+
int _gnutls_mac_fast(gnutls_mac_algorithm_t algorithm, const void *key,
int keylen, const void *text, size_t textlen,
void *digest);
typedef int (*gnutls_mac_fast_func) (gnutls_mac_algorithm_t, const void *nonce,
size_t nonce_size, const void *key, size_t keysize,
const void *text, size_t textsize, void *digest);
+typedef void *(*gnutls_mac_copy_func) (const void *ctx);
int
gnutls_crypto_register_mac(gnutls_mac_algorithm_t mac,