diff options
Diffstat (limited to 'include/crypto')
| -rw-r--r-- | include/crypto/ablk_helper.h | 31 | ||||
| -rw-r--r-- | include/crypto/algapi.h | 18 | ||||
| -rw-r--r-- | include/crypto/authenc.h | 12 | ||||
| -rw-r--r-- | include/crypto/hash_info.h | 40 | ||||
| -rw-r--r-- | include/crypto/public_key.h | 25 | ||||
| -rw-r--r-- | include/crypto/scatterwalk.h | 3 |
6 files changed, 110 insertions, 19 deletions
diff --git a/include/crypto/ablk_helper.h b/include/crypto/ablk_helper.h new file mode 100644 index 000000000000..4f93df50c23e --- /dev/null +++ b/include/crypto/ablk_helper.h | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | /* | ||
| 2 | * Shared async block cipher helpers | ||
| 3 | */ | ||
| 4 | |||
| 5 | #ifndef _CRYPTO_ABLK_HELPER_H | ||
| 6 | #define _CRYPTO_ABLK_HELPER_H | ||
| 7 | |||
| 8 | #include <linux/crypto.h> | ||
| 9 | #include <linux/kernel.h> | ||
| 10 | #include <crypto/cryptd.h> | ||
| 11 | |||
| 12 | struct async_helper_ctx { | ||
| 13 | struct cryptd_ablkcipher *cryptd_tfm; | ||
| 14 | }; | ||
| 15 | |||
| 16 | extern int ablk_set_key(struct crypto_ablkcipher *tfm, const u8 *key, | ||
| 17 | unsigned int key_len); | ||
| 18 | |||
| 19 | extern int __ablk_encrypt(struct ablkcipher_request *req); | ||
| 20 | |||
| 21 | extern int ablk_encrypt(struct ablkcipher_request *req); | ||
| 22 | |||
| 23 | extern int ablk_decrypt(struct ablkcipher_request *req); | ||
| 24 | |||
| 25 | extern void ablk_exit(struct crypto_tfm *tfm); | ||
| 26 | |||
| 27 | extern int ablk_init_common(struct crypto_tfm *tfm, const char *drv_name); | ||
| 28 | |||
| 29 | extern int ablk_init(struct crypto_tfm *tfm); | ||
| 30 | |||
| 31 | #endif /* _CRYPTO_ABLK_HELPER_H */ | ||
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h index 418d270e1806..e73c19e90e38 100644 --- a/include/crypto/algapi.h +++ b/include/crypto/algapi.h | |||
| @@ -386,5 +386,21 @@ static inline int crypto_requires_sync(u32 type, u32 mask) | |||
| 386 | return (type ^ CRYPTO_ALG_ASYNC) & mask & CRYPTO_ALG_ASYNC; | 386 | return (type ^ CRYPTO_ALG_ASYNC) & mask & CRYPTO_ALG_ASYNC; |
| 387 | } | 387 | } |
| 388 | 388 | ||
| 389 | #endif /* _CRYPTO_ALGAPI_H */ | 389 | noinline unsigned long __crypto_memneq(const void *a, const void *b, size_t size); |
| 390 | |||
| 391 | /** | ||
| 392 | * crypto_memneq - Compare two areas of memory without leaking | ||
| 393 | * timing information. | ||
| 394 | * | ||
| 395 | * @a: One area of memory | ||
| 396 | * @b: Another area of memory | ||
| 397 | * @size: The size of the area. | ||
| 398 | * | ||
| 399 | * Returns 0 when data is equal, 1 otherwise. | ||
| 400 | */ | ||
| 401 | static inline int crypto_memneq(const void *a, const void *b, size_t size) | ||
| 402 | { | ||
| 403 | return __crypto_memneq(a, b, size) != 0UL ? 1 : 0; | ||
| 404 | } | ||
| 390 | 405 | ||
| 406 | #endif /* _CRYPTO_ALGAPI_H */ | ||
diff --git a/include/crypto/authenc.h b/include/crypto/authenc.h index e47b044929a8..6775059539b5 100644 --- a/include/crypto/authenc.h +++ b/include/crypto/authenc.h | |||
| @@ -23,5 +23,15 @@ struct crypto_authenc_key_param { | |||
| 23 | __be32 enckeylen; | 23 | __be32 enckeylen; |
| 24 | }; | 24 | }; |
| 25 | 25 | ||
| 26 | #endif /* _CRYPTO_AUTHENC_H */ | 26 | struct crypto_authenc_keys { |
| 27 | const u8 *authkey; | ||
| 28 | const u8 *enckey; | ||
| 29 | |||
| 30 | unsigned int authkeylen; | ||
| 31 | unsigned int enckeylen; | ||
| 32 | }; | ||
| 27 | 33 | ||
| 34 | int crypto_authenc_extractkeys(struct crypto_authenc_keys *keys, const u8 *key, | ||
| 35 | unsigned int keylen); | ||
| 36 | |||
| 37 | #endif /* _CRYPTO_AUTHENC_H */ | ||
diff --git a/include/crypto/hash_info.h b/include/crypto/hash_info.h new file mode 100644 index 000000000000..e1e5a3e5dd1b --- /dev/null +++ b/include/crypto/hash_info.h | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | /* | ||
| 2 | * Hash Info: Hash algorithms information | ||
| 3 | * | ||
| 4 | * Copyright (c) 2013 Dmitry Kasatkin <d.kasatkin@samsung.com> | ||
| 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) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | */ | ||
| 12 | |||
| 13 | #ifndef _CRYPTO_HASH_INFO_H | ||
| 14 | #define _CRYPTO_HASH_INFO_H | ||
| 15 | |||
| 16 | #include <crypto/sha.h> | ||
| 17 | #include <crypto/md5.h> | ||
| 18 | |||
| 19 | #include <uapi/linux/hash_info.h> | ||
| 20 | |||
| 21 | /* not defined in include/crypto/ */ | ||
| 22 | #define RMD128_DIGEST_SIZE 16 | ||
| 23 | #define RMD160_DIGEST_SIZE 20 | ||
| 24 | #define RMD256_DIGEST_SIZE 32 | ||
| 25 | #define RMD320_DIGEST_SIZE 40 | ||
| 26 | |||
| 27 | /* not defined in include/crypto/ */ | ||
| 28 | #define WP512_DIGEST_SIZE 64 | ||
| 29 | #define WP384_DIGEST_SIZE 48 | ||
| 30 | #define WP256_DIGEST_SIZE 32 | ||
| 31 | |||
| 32 | /* not defined in include/crypto/ */ | ||
| 33 | #define TGR128_DIGEST_SIZE 16 | ||
| 34 | #define TGR160_DIGEST_SIZE 20 | ||
| 35 | #define TGR192_DIGEST_SIZE 24 | ||
| 36 | |||
| 37 | extern const char *const hash_algo_name[HASH_ALGO__LAST]; | ||
| 38 | extern const int hash_digest_size[HASH_ALGO__LAST]; | ||
| 39 | |||
| 40 | #endif /* _CRYPTO_HASH_INFO_H */ | ||
diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h index f5b0224c9967..fc09732613ad 100644 --- a/include/crypto/public_key.h +++ b/include/crypto/public_key.h | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #define _LINUX_PUBLIC_KEY_H | 15 | #define _LINUX_PUBLIC_KEY_H |
| 16 | 16 | ||
| 17 | #include <linux/mpi.h> | 17 | #include <linux/mpi.h> |
| 18 | #include <crypto/hash_info.h> | ||
| 18 | 19 | ||
| 19 | enum pkey_algo { | 20 | enum pkey_algo { |
| 20 | PKEY_ALGO_DSA, | 21 | PKEY_ALGO_DSA, |
| @@ -22,21 +23,11 @@ enum pkey_algo { | |||
| 22 | PKEY_ALGO__LAST | 23 | PKEY_ALGO__LAST |
| 23 | }; | 24 | }; |
| 24 | 25 | ||
| 25 | extern const char *const pkey_algo[PKEY_ALGO__LAST]; | 26 | extern const char *const pkey_algo_name[PKEY_ALGO__LAST]; |
| 27 | extern const struct public_key_algorithm *pkey_algo[PKEY_ALGO__LAST]; | ||
| 26 | 28 | ||
| 27 | enum pkey_hash_algo { | 29 | /* asymmetric key implementation supports only up to SHA224 */ |
| 28 | PKEY_HASH_MD4, | 30 | #define PKEY_HASH__LAST (HASH_ALGO_SHA224 + 1) |
| 29 | PKEY_HASH_MD5, | ||
| 30 | PKEY_HASH_SHA1, | ||
| 31 | PKEY_HASH_RIPE_MD_160, | ||
| 32 | PKEY_HASH_SHA256, | ||
| 33 | PKEY_HASH_SHA384, | ||
| 34 | PKEY_HASH_SHA512, | ||
| 35 | PKEY_HASH_SHA224, | ||
| 36 | PKEY_HASH__LAST | ||
| 37 | }; | ||
| 38 | |||
| 39 | extern const char *const pkey_hash_algo[PKEY_HASH__LAST]; | ||
| 40 | 31 | ||
| 41 | enum pkey_id_type { | 32 | enum pkey_id_type { |
| 42 | PKEY_ID_PGP, /* OpenPGP generated key ID */ | 33 | PKEY_ID_PGP, /* OpenPGP generated key ID */ |
| @@ -44,7 +35,7 @@ enum pkey_id_type { | |||
| 44 | PKEY_ID_TYPE__LAST | 35 | PKEY_ID_TYPE__LAST |
| 45 | }; | 36 | }; |
| 46 | 37 | ||
| 47 | extern const char *const pkey_id_type[PKEY_ID_TYPE__LAST]; | 38 | extern const char *const pkey_id_type_name[PKEY_ID_TYPE__LAST]; |
| 48 | 39 | ||
| 49 | /* | 40 | /* |
| 50 | * Cryptographic data for the public-key subtype of the asymmetric key type. | 41 | * Cryptographic data for the public-key subtype of the asymmetric key type. |
| @@ -59,6 +50,7 @@ struct public_key { | |||
| 59 | #define PKEY_CAN_DECRYPT 0x02 | 50 | #define PKEY_CAN_DECRYPT 0x02 |
| 60 | #define PKEY_CAN_SIGN 0x04 | 51 | #define PKEY_CAN_SIGN 0x04 |
| 61 | #define PKEY_CAN_VERIFY 0x08 | 52 | #define PKEY_CAN_VERIFY 0x08 |
| 53 | enum pkey_algo pkey_algo : 8; | ||
| 62 | enum pkey_id_type id_type : 8; | 54 | enum pkey_id_type id_type : 8; |
| 63 | union { | 55 | union { |
| 64 | MPI mpi[5]; | 56 | MPI mpi[5]; |
| @@ -88,7 +80,8 @@ struct public_key_signature { | |||
| 88 | u8 *digest; | 80 | u8 *digest; |
| 89 | u8 digest_size; /* Number of bytes in digest */ | 81 | u8 digest_size; /* Number of bytes in digest */ |
| 90 | u8 nr_mpi; /* Occupancy of mpi[] */ | 82 | u8 nr_mpi; /* Occupancy of mpi[] */ |
| 91 | enum pkey_hash_algo pkey_hash_algo : 8; | 83 | enum pkey_algo pkey_algo : 8; |
| 84 | enum hash_algo pkey_hash_algo : 8; | ||
| 92 | union { | 85 | union { |
| 93 | MPI mpi[2]; | 86 | MPI mpi[2]; |
| 94 | struct { | 87 | struct { |
diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h index 13621cc8cf4c..6a626a507b8c 100644 --- a/include/crypto/scatterwalk.h +++ b/include/crypto/scatterwalk.h | |||
| @@ -36,6 +36,7 @@ static inline void scatterwalk_sg_chain(struct scatterlist *sg1, int num, | |||
| 36 | { | 36 | { |
| 37 | sg_set_page(&sg1[num - 1], (void *)sg2, 0, 0); | 37 | sg_set_page(&sg1[num - 1], (void *)sg2, 0, 0); |
| 38 | sg1[num - 1].page_link &= ~0x02; | 38 | sg1[num - 1].page_link &= ~0x02; |
| 39 | sg1[num - 1].page_link |= 0x01; | ||
| 39 | } | 40 | } |
| 40 | 41 | ||
| 41 | static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg) | 42 | static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg) |
| @@ -43,7 +44,7 @@ static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg) | |||
| 43 | if (sg_is_last(sg)) | 44 | if (sg_is_last(sg)) |
| 44 | return NULL; | 45 | return NULL; |
| 45 | 46 | ||
| 46 | return (++sg)->length ? sg : (void *)sg_page(sg); | 47 | return (++sg)->length ? sg : sg_chain_ptr(sg); |
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | static inline void scatterwalk_crypto_chain(struct scatterlist *head, | 50 | static inline void scatterwalk_crypto_chain(struct scatterlist *head, |
