hash.h (b68a7ec1e9a3efac53ae26a1658a553825a2375c) hash.h (cac5818c25d0423bda73e2b6997404ed0a7ed9e3)
1/*
2 * Hash: Hash algorithms under the crypto API
3 *
4 * Copyright (c) 2008 Herbert Xu <herbert@gondor.apana.org.au>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)

--- 398 unchanged lines hidden (view full) ---

407 * The caller provided key is set for the ahash cipher. The cipher
408 * handle must point to a keyed hash in order for this function to succeed.
409 *
410 * Return: 0 if the setting of the key was successful; < 0 if an error occurred
411 */
412int crypto_ahash_setkey(struct crypto_ahash *tfm, const u8 *key,
413 unsigned int keylen);
414
1/*
2 * Hash: Hash algorithms under the crypto API
3 *
4 * Copyright (c) 2008 Herbert Xu <herbert@gondor.apana.org.au>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)

--- 398 unchanged lines hidden (view full) ---

407 * The caller provided key is set for the ahash cipher. The cipher
408 * handle must point to a keyed hash in order for this function to succeed.
409 *
410 * Return: 0 if the setting of the key was successful; < 0 if an error occurred
411 */
412int crypto_ahash_setkey(struct crypto_ahash *tfm, const u8 *key,
413 unsigned int keylen);
414
415static inline void crypto_stat_ahash_update(struct ahash_request *req, int ret)
416{
417#ifdef CONFIG_CRYPTO_STATS
418 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
419
420 if (ret && ret != -EINPROGRESS && ret != -EBUSY)
421 atomic_inc(&tfm->base.__crt_alg->hash_err_cnt);
422 else
423 atomic64_add(req->nbytes, &tfm->base.__crt_alg->hash_tlen);
424#endif
425}
426
427static inline void crypto_stat_ahash_final(struct ahash_request *req, int ret)
428{
429#ifdef CONFIG_CRYPTO_STATS
430 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
431
432 if (ret && ret != -EINPROGRESS && ret != -EBUSY) {
433 atomic_inc(&tfm->base.__crt_alg->hash_err_cnt);
434 } else {
435 atomic_inc(&tfm->base.__crt_alg->hash_cnt);
436 atomic64_add(req->nbytes, &tfm->base.__crt_alg->hash_tlen);
437 }
438#endif
439}
440
415/**
416 * crypto_ahash_finup() - update and finalize message digest
417 * @req: reference to the ahash_request handle that holds all information
418 * needed to perform the cipher operation
419 *
420 * This function is a "short-hand" for the function calls of
421 * crypto_ahash_update and crypto_ahash_final. The parameters have the same
422 * meaning as discussed for those separate functions.

--- 98 unchanged lines hidden (view full) ---

521 * Updates the message digest state of the &ahash_request handle. The input data
522 * is pointed to by the scatter/gather list registered in the &ahash_request
523 * handle
524 *
525 * Return: see crypto_ahash_final()
526 */
527static inline int crypto_ahash_update(struct ahash_request *req)
528{
441/**
442 * crypto_ahash_finup() - update and finalize message digest
443 * @req: reference to the ahash_request handle that holds all information
444 * needed to perform the cipher operation
445 *
446 * This function is a "short-hand" for the function calls of
447 * crypto_ahash_update and crypto_ahash_final. The parameters have the same
448 * meaning as discussed for those separate functions.

--- 98 unchanged lines hidden (view full) ---

547 * Updates the message digest state of the &ahash_request handle. The input data
548 * is pointed to by the scatter/gather list registered in the &ahash_request
549 * handle
550 *
551 * Return: see crypto_ahash_final()
552 */
553static inline int crypto_ahash_update(struct ahash_request *req)
554{
529 return crypto_ahash_reqtfm(req)->update(req);
555 int ret;
556
557 ret = crypto_ahash_reqtfm(req)->update(req);
558 crypto_stat_ahash_update(req, ret);
559 return ret;
530}
531
532/**
533 * DOC: Asynchronous Hash Request Handle
534 *
535 * The &ahash_request data structure contains all pointers to data
536 * required for the asynchronous cipher operation. This includes the cipher
537 * handle (which can be used by multiple &ahash_request instances), pointer

--- 409 unchanged lines hidden ---
560}
561
562/**
563 * DOC: Asynchronous Hash Request Handle
564 *
565 * The &ahash_request data structure contains all pointers to data
566 * required for the asynchronous cipher operation. This includes the cipher
567 * handle (which can be used by multiple &ahash_request instances), pointer

--- 409 unchanged lines hidden ---