aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/crypto.h
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2008-07-10 04:01:22 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2008-07-10 08:35:18 -0400
commit18e33e6d5cc0495826f5245777cd267732815e01 (patch)
tree5cf0151630a63c27e06daad39556c423d4e2ef36 /include/linux/crypto.h
parent5773a3e6e396d5fd9de58372abe6a86b7e258e3e (diff)
crypto: hash - Move ahash functions into crypto/hash.h
All new crypto interfaces should go into individual files as much as possible in order to ensure that crypto.h does not collapse under its own weight. This patch moves the ahash code into crypto/hash.h and crypto/internal/hash.h respectively. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/linux/crypto.h')
-rw-r--r--include/linux/crypto.h136
1 files changed, 0 insertions, 136 deletions
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index 68ef293644d3..c43dc47fdf75 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -481,10 +481,6 @@ struct crypto_hash {
481 struct crypto_tfm base; 481 struct crypto_tfm base;
482}; 482};
483 483
484struct crypto_ahash {
485 struct crypto_tfm base;
486};
487
488enum { 484enum {
489 CRYPTOA_UNSPEC, 485 CRYPTOA_UNSPEC,
490 CRYPTOA_ALG, 486 CRYPTOA_ALG,
@@ -1308,137 +1304,5 @@ static inline int crypto_comp_decompress(struct crypto_comp *tfm,
1308 src, slen, dst, dlen); 1304 src, slen, dst, dlen);
1309} 1305}
1310 1306
1311static inline struct crypto_ahash *__crypto_ahash_cast(struct crypto_tfm *tfm)
1312{
1313 return (struct crypto_ahash *)tfm;
1314}
1315
1316static inline struct crypto_ahash *crypto_alloc_ahash(const char *alg_name,
1317 u32 type, u32 mask)
1318{
1319 type &= ~CRYPTO_ALG_TYPE_MASK;
1320 mask &= ~CRYPTO_ALG_TYPE_MASK;
1321 type |= CRYPTO_ALG_TYPE_AHASH;
1322 mask |= CRYPTO_ALG_TYPE_AHASH_MASK;
1323
1324 return __crypto_ahash_cast(crypto_alloc_base(alg_name, type, mask));
1325}
1326
1327static inline struct crypto_tfm *crypto_ahash_tfm(struct crypto_ahash *tfm)
1328{
1329 return &tfm->base;
1330}
1331
1332static inline void crypto_free_ahash(struct crypto_ahash *tfm)
1333{
1334 crypto_free_tfm(crypto_ahash_tfm(tfm));
1335}
1336
1337static inline unsigned int crypto_ahash_alignmask(
1338 struct crypto_ahash *tfm)
1339{
1340 return crypto_tfm_alg_alignmask(crypto_ahash_tfm(tfm));
1341}
1342
1343static inline struct ahash_tfm *crypto_ahash_crt(struct crypto_ahash *tfm)
1344{
1345 return &crypto_ahash_tfm(tfm)->crt_ahash;
1346}
1347
1348static inline unsigned int crypto_ahash_digestsize(struct crypto_ahash *tfm)
1349{
1350 return crypto_ahash_crt(tfm)->digestsize;
1351}
1352
1353static inline u32 crypto_ahash_get_flags(struct crypto_ahash *tfm)
1354{
1355 return crypto_tfm_get_flags(crypto_ahash_tfm(tfm));
1356}
1357
1358static inline void crypto_ahash_set_flags(struct crypto_ahash *tfm, u32 flags)
1359{
1360 crypto_tfm_set_flags(crypto_ahash_tfm(tfm), flags);
1361}
1362
1363static inline void crypto_ahash_clear_flags(struct crypto_ahash *tfm, u32 flags)
1364{
1365 crypto_tfm_clear_flags(crypto_ahash_tfm(tfm), flags);
1366}
1367
1368static inline struct crypto_ahash *crypto_ahash_reqtfm(
1369 struct ahash_request *req)
1370{
1371 return __crypto_ahash_cast(req->base.tfm);
1372}
1373
1374static inline unsigned int crypto_ahash_reqsize(struct crypto_ahash *tfm)
1375{
1376 return crypto_ahash_crt(tfm)->reqsize;
1377}
1378
1379static inline int crypto_ahash_setkey(struct crypto_ahash *tfm,
1380 const u8 *key, unsigned int keylen)
1381{
1382 struct ahash_tfm *crt = crypto_ahash_crt(tfm);
1383
1384 return crt->setkey(tfm, key, keylen);
1385}
1386
1387static inline int crypto_ahash_digest(struct ahash_request *req)
1388{
1389 struct ahash_tfm *crt = crypto_ahash_crt(crypto_ahash_reqtfm(req));
1390 return crt->digest(req);
1391}
1392
1393static inline void ahash_request_set_tfm(struct ahash_request *req,
1394 struct crypto_ahash *tfm)
1395{
1396 req->base.tfm = crypto_ahash_tfm(tfm);
1397}
1398
1399static inline struct ahash_request *ahash_request_alloc(
1400 struct crypto_ahash *tfm, gfp_t gfp)
1401{
1402 struct ahash_request *req;
1403
1404 req = kmalloc(sizeof(struct ahash_request) +
1405 crypto_ahash_reqsize(tfm), gfp);
1406
1407 if (likely(req))
1408 ahash_request_set_tfm(req, tfm);
1409
1410 return req;
1411}
1412
1413static inline void ahash_request_free(struct ahash_request *req)
1414{
1415 kfree(req);
1416}
1417
1418static inline struct ahash_request *ahash_request_cast(
1419 struct crypto_async_request *req)
1420{
1421 return container_of(req, struct ahash_request, base);
1422}
1423
1424static inline void ahash_request_set_callback(struct ahash_request *req,
1425 u32 flags,
1426 crypto_completion_t complete,
1427 void *data)
1428{
1429 req->base.complete = complete;
1430 req->base.data = data;
1431 req->base.flags = flags;
1432}
1433
1434static inline void ahash_request_set_crypt(struct ahash_request *req,
1435 struct scatterlist *src, u8 *result,
1436 unsigned int nbytes)
1437{
1438 req->src = src;
1439 req->nbytes = nbytes;
1440 req->result = result;
1441}
1442
1443#endif /* _LINUX_CRYPTO_H */ 1307#endif /* _LINUX_CRYPTO_H */
1444 1308