Lines Matching defs:hash
181 struct iked_hash *hash;
272 log_debug("%s: hash type %s not supported", __func__,
279 if ((hash = calloc(1, sizeof(*hash))) == NULL) {
280 log_debug("%s: alloc hash", __func__);
284 hash->hash_type = type;
285 hash->hash_id = id;
286 hash->hash_priv = md;
287 hash->hash_ctx = NULL;
288 hash->hash_trunc = trunc;
289 hash->hash_length = length;
290 hash->hash_fixedkey = fixedkey;
291 hash->hash_isaead = isaead;
294 return (hash);
296 hash->hash_ctx = HMAC_CTX_new();
297 if (hash->hash_ctx == NULL) {
298 log_debug("%s: alloc hash ctx", __func__);
299 hash_free(hash);
303 return (hash);
307 hash_setkey(struct iked_hash *hash, void *key, size_t keylen)
309 ibuf_free(hash->hash_key);
310 if ((hash->hash_key = ibuf_new(key, keylen)) == NULL) {
311 log_debug("%s: alloc hash key", __func__);
314 return (hash->hash_key);
318 hash_free(struct iked_hash *hash)
320 if (hash == NULL)
322 HMAC_CTX_free(hash->hash_ctx);
323 ibuf_free(hash->hash_key);
324 free(hash);
328 hash_init(struct iked_hash *hash)
330 HMAC_Init_ex(hash->hash_ctx, ibuf_data(hash->hash_key),
331 ibuf_size(hash->hash_key), hash->hash_priv, NULL);
335 hash_update(struct iked_hash *hash, void *buf, size_t len)
337 HMAC_Update(hash->hash_ctx, buf, len);
341 hash_final(struct iked_hash *hash, void *buf, size_t *len)
345 HMAC_Final(hash->hash_ctx, buf, &length);
349 if (hash->hash_trunc && *len > hash->hash_trunc)
350 *len = hash->hash_trunc;
354 hash_length(struct iked_hash *hash)
356 if (hash->hash_trunc)
357 return (hash->hash_trunc);
358 return (hash->hash_length);
362 hash_keylength(struct iked_hash *hash)
364 return (hash->hash_length);
731 log_debug("%s: alloc hash ctx", __func__);
971 /* Prefix signature hash with encoded type */
1008 /* Export size of encoded signature hash type */