diff options
Diffstat (limited to 'include/crypto')
| -rw-r--r-- | include/crypto/ablk_helper.h | 31 | ||||
| -rw-r--r-- | include/crypto/algapi.h | 27 | ||||
| -rw-r--r-- | include/crypto/authenc.h | 12 | ||||
| -rw-r--r-- | include/crypto/hash_info.h | 40 | ||||
| -rw-r--r-- | include/crypto/internal/hash.h | 13 | ||||
| -rw-r--r-- | include/crypto/null.h | 11 | ||||
| -rw-r--r-- | include/crypto/public_key.h | 25 | ||||
| -rw-r--r-- | include/crypto/scatterwalk.h | 3 | 
8 files changed, 142 insertions, 20 deletions
diff --git a/include/crypto/ablk_helper.h b/include/crypto/ablk_helper.h new file mode 100644 index 00000000000..4f93df50c23 --- /dev/null +++ b/include/crypto/ablk_helper.h @@ -0,0 +1,31 @@ +/* + * Shared async block cipher helpers + */ + +#ifndef _CRYPTO_ABLK_HELPER_H +#define _CRYPTO_ABLK_HELPER_H + +#include <linux/crypto.h> +#include <linux/kernel.h> +#include <crypto/cryptd.h> + +struct async_helper_ctx { +	struct cryptd_ablkcipher *cryptd_tfm; +}; + +extern int ablk_set_key(struct crypto_ablkcipher *tfm, const u8 *key, +			unsigned int key_len); + +extern int __ablk_encrypt(struct ablkcipher_request *req); + +extern int ablk_encrypt(struct ablkcipher_request *req); + +extern int ablk_decrypt(struct ablkcipher_request *req); + +extern void ablk_exit(struct crypto_tfm *tfm); + +extern int ablk_init_common(struct crypto_tfm *tfm, const char *drv_name); + +extern int ablk_init(struct crypto_tfm *tfm); + +#endif /* _CRYPTO_ABLK_HELPER_H */ diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h index 418d270e180..016c2f110f6 100644 --- a/include/crypto/algapi.h +++ b/include/crypto/algapi.h @@ -100,9 +100,12 @@ struct blkcipher_walk {  	void *page;  	u8 *buffer;  	u8 *iv; +	unsigned int ivsize;  	int flags; -	unsigned int blocksize; +	unsigned int walk_blocksize; +	unsigned int cipher_blocksize; +	unsigned int alignmask;  };  struct ablkcipher_walk { @@ -192,6 +195,10 @@ int blkcipher_walk_phys(struct blkcipher_desc *desc,  int blkcipher_walk_virt_block(struct blkcipher_desc *desc,  			      struct blkcipher_walk *walk,  			      unsigned int blocksize); +int blkcipher_aead_walk_virt_block(struct blkcipher_desc *desc, +				   struct blkcipher_walk *walk, +				   struct crypto_aead *tfm, +				   unsigned int blocksize);  int ablkcipher_walk_done(struct ablkcipher_request *req,  			 struct ablkcipher_walk *walk, int err); @@ -386,5 +393,21 @@ static inline int crypto_requires_sync(u32 type, u32 mask)  	return (type ^ CRYPTO_ALG_ASYNC) & mask & CRYPTO_ALG_ASYNC;  } -#endif	/* _CRYPTO_ALGAPI_H */ +noinline unsigned long __crypto_memneq(const void *a, const void *b, size_t size); + +/** + * crypto_memneq - Compare two areas of memory without leaking + *		   timing information. + * + * @a: One area of memory + * @b: Another area of memory + * @size: The size of the area. + * + * Returns 0 when data is equal, 1 otherwise. + */ +static inline int crypto_memneq(const void *a, const void *b, size_t size) +{ +	return __crypto_memneq(a, b, size) != 0UL ? 1 : 0; +} +#endif	/* _CRYPTO_ALGAPI_H */ diff --git a/include/crypto/authenc.h b/include/crypto/authenc.h index e47b044929a..6775059539b 100644 --- a/include/crypto/authenc.h +++ b/include/crypto/authenc.h @@ -23,5 +23,15 @@ struct crypto_authenc_key_param {  	__be32 enckeylen;  }; -#endif	/* _CRYPTO_AUTHENC_H */ +struct crypto_authenc_keys { +	const u8 *authkey; +	const u8 *enckey; + +	unsigned int authkeylen; +	unsigned int enckeylen; +}; +int crypto_authenc_extractkeys(struct crypto_authenc_keys *keys, const u8 *key, +			       unsigned int keylen); + +#endif	/* _CRYPTO_AUTHENC_H */ diff --git a/include/crypto/hash_info.h b/include/crypto/hash_info.h new file mode 100644 index 00000000000..e1e5a3e5dd1 --- /dev/null +++ b/include/crypto/hash_info.h @@ -0,0 +1,40 @@ +/* + * Hash Info: Hash algorithms information + * + * Copyright (c) 2013 Dmitry Kasatkin <d.kasatkin@samsung.com> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + */ + +#ifndef _CRYPTO_HASH_INFO_H +#define _CRYPTO_HASH_INFO_H + +#include <crypto/sha.h> +#include <crypto/md5.h> + +#include <uapi/linux/hash_info.h> + +/* not defined in include/crypto/ */ +#define RMD128_DIGEST_SIZE      16 +#define RMD160_DIGEST_SIZE	20 +#define RMD256_DIGEST_SIZE      32 +#define RMD320_DIGEST_SIZE      40 + +/* not defined in include/crypto/ */ +#define WP512_DIGEST_SIZE	64 +#define WP384_DIGEST_SIZE	48 +#define WP256_DIGEST_SIZE	32 + +/* not defined in include/crypto/ */ +#define TGR128_DIGEST_SIZE 16 +#define TGR160_DIGEST_SIZE 20 +#define TGR192_DIGEST_SIZE 24 + +extern const char *const hash_algo_name[HASH_ALGO__LAST]; +extern const int hash_digest_size[HASH_ALGO__LAST]; + +#endif /* _CRYPTO_HASH_INFO_H */ diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h index 821eae8cbd8..9b6f32a6cad 100644 --- a/include/crypto/internal/hash.h +++ b/include/crypto/internal/hash.h @@ -55,15 +55,28 @@ extern const struct crypto_type crypto_ahash_type;  int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err);  int crypto_hash_walk_first(struct ahash_request *req,  			   struct crypto_hash_walk *walk); +int crypto_ahash_walk_first(struct ahash_request *req, +			   struct crypto_hash_walk *walk);  int crypto_hash_walk_first_compat(struct hash_desc *hdesc,  				  struct crypto_hash_walk *walk,  				  struct scatterlist *sg, unsigned int len); +static inline int crypto_ahash_walk_done(struct crypto_hash_walk *walk, +					 int err) +{ +	return crypto_hash_walk_done(walk, err); +} +  static inline int crypto_hash_walk_last(struct crypto_hash_walk *walk)  {  	return !(walk->entrylen | walk->total);  } +static inline int crypto_ahash_walk_last(struct crypto_hash_walk *walk) +{ +	return crypto_hash_walk_last(walk); +} +  int crypto_register_ahash(struct ahash_alg *alg);  int crypto_unregister_ahash(struct ahash_alg *alg);  int ahash_register_instance(struct crypto_template *tmpl, diff --git a/include/crypto/null.h b/include/crypto/null.h new file mode 100644 index 00000000000..b7c864cc70d --- /dev/null +++ b/include/crypto/null.h @@ -0,0 +1,11 @@ +/* Values for NULL algorithms */ + +#ifndef _CRYPTO_NULL_H +#define _CRYPTO_NULL_H + +#define NULL_KEY_SIZE		0 +#define NULL_BLOCK_SIZE		1 +#define NULL_DIGEST_SIZE	0 +#define NULL_IV_SIZE		0 + +#endif diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h index f5b0224c996..fc09732613a 100644 --- a/include/crypto/public_key.h +++ b/include/crypto/public_key.h @@ -15,6 +15,7 @@  #define _LINUX_PUBLIC_KEY_H  #include <linux/mpi.h> +#include <crypto/hash_info.h>  enum pkey_algo {  	PKEY_ALGO_DSA, @@ -22,21 +23,11 @@ enum pkey_algo {  	PKEY_ALGO__LAST  }; -extern const char *const pkey_algo[PKEY_ALGO__LAST]; +extern const char *const pkey_algo_name[PKEY_ALGO__LAST]; +extern const struct public_key_algorithm *pkey_algo[PKEY_ALGO__LAST]; -enum pkey_hash_algo { -	PKEY_HASH_MD4, -	PKEY_HASH_MD5, -	PKEY_HASH_SHA1, -	PKEY_HASH_RIPE_MD_160, -	PKEY_HASH_SHA256, -	PKEY_HASH_SHA384, -	PKEY_HASH_SHA512, -	PKEY_HASH_SHA224, -	PKEY_HASH__LAST -}; - -extern const char *const pkey_hash_algo[PKEY_HASH__LAST]; +/* asymmetric key implementation supports only up to SHA224 */ +#define PKEY_HASH__LAST		(HASH_ALGO_SHA224 + 1)  enum pkey_id_type {  	PKEY_ID_PGP,		/* OpenPGP generated key ID */ @@ -44,7 +35,7 @@ enum pkey_id_type {  	PKEY_ID_TYPE__LAST  }; -extern const char *const pkey_id_type[PKEY_ID_TYPE__LAST]; +extern const char *const pkey_id_type_name[PKEY_ID_TYPE__LAST];  /*   * Cryptographic data for the public-key subtype of the asymmetric key type. @@ -59,6 +50,7 @@ struct public_key {  #define PKEY_CAN_DECRYPT	0x02  #define PKEY_CAN_SIGN		0x04  #define PKEY_CAN_VERIFY		0x08 +	enum pkey_algo pkey_algo : 8;  	enum pkey_id_type id_type : 8;  	union {  		MPI	mpi[5]; @@ -88,7 +80,8 @@ struct public_key_signature {  	u8 *digest;  	u8 digest_size;			/* Number of bytes in digest */  	u8 nr_mpi;			/* Occupancy of mpi[] */ -	enum pkey_hash_algo pkey_hash_algo : 8; +	enum pkey_algo pkey_algo : 8; +	enum hash_algo pkey_hash_algo : 8;  	union {  		MPI mpi[2];  		struct { diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h index 13621cc8cf4..6a626a507b8 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,  {  	sg_set_page(&sg1[num - 1], (void *)sg2, 0, 0);  	sg1[num - 1].page_link &= ~0x02; +	sg1[num - 1].page_link |= 0x01;  }  static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg) @@ -43,7 +44,7 @@ static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg)  	if (sg_is_last(sg))  		return NULL; -	return (++sg)->length ? sg : (void *)sg_page(sg); +	return (++sg)->length ? sg : sg_chain_ptr(sg);  }  static inline void scatterwalk_crypto_chain(struct scatterlist *head,  | 
