diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2016-02-01 21:36:50 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-02-06 15:33:11 +0800 |
commit | 8bc618d6a2e05f8f4d26d46b63d19ddfdcba7869 (patch) | |
tree | f168ba982680c17a402110d24b66607f3cec7b8e /Documentation/crypto/api-intro.txt | |
parent | 0660511c0beeccdc240479f29d5ecd8362115be3 (diff) | |
download | linux-stable-8bc618d6a2e05f8f4d26d46b63d19ddfdcba7869.tar.gz linux-stable-8bc618d6a2e05f8f4d26d46b63d19ddfdcba7869.tar.bz2 linux-stable-8bc618d6a2e05f8f4d26d46b63d19ddfdcba7869.zip |
crypto: doc - Use ahash
This patch replaces the crypto_hash example in api-intro.txt with
crypto_ahash.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'Documentation/crypto/api-intro.txt')
-rw-r--r-- | Documentation/crypto/api-intro.txt | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/Documentation/crypto/api-intro.txt b/Documentation/crypto/api-intro.txt index 8b49302712a8..beda682e8d77 100644 --- a/Documentation/crypto/api-intro.txt +++ b/Documentation/crypto/api-intro.txt @@ -49,28 +49,33 @@ under development. Here's an example of how to use the API: - #include <linux/crypto.h> + #include <crypto/ahash.h> #include <linux/err.h> #include <linux/scatterlist.h> struct scatterlist sg[2]; char result[128]; - struct crypto_hash *tfm; - struct hash_desc desc; + struct crypto_ahash *tfm; + struct ahash_request *req; - tfm = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC); + tfm = crypto_alloc_ahash("md5", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(tfm)) fail(); /* ... set up the scatterlists ... */ - desc.tfm = tfm; - desc.flags = 0; - - if (crypto_hash_digest(&desc, sg, 2, result)) + req = ahash_request_alloc(tfm, GFP_ATOMIC); + if (!req) fail(); + + ahash_request_set_callback(req, 0, NULL, NULL); + ahash_request_set_crypt(req, sg, result, 2); - crypto_free_hash(tfm); + if (crypto_ahash_digest(req)) + fail(); + + ahash_request_free(req); + crypto_free_ahash(tfm); Many real examples are available in the regression test module (tcrypt.c). |