From c6da2cfeb05178a11c6d062a06f8078150ee492f Mon Sep 17 00:00:00 2001 From: codeworkx Date: Sat, 2 Jun 2012 13:09:29 +0200 Subject: samsung update 1 --- include/crypto/aead.h | 21 +++++++++++++++++++-- include/crypto/algapi.h | 1 + include/crypto/compress.h | 40 ++++++++++++++++++++++++++++++++++++++++ include/crypto/hash.h | 34 ++++++++++++++++++++++++++++++++-- include/crypto/rng.h | 5 +++++ include/crypto/skcipher.h | 18 +++++++++++++++--- 6 files changed, 112 insertions(+), 7 deletions(-) (limited to 'include/crypto') diff --git a/include/crypto/aead.h b/include/crypto/aead.h index 0edf949..2281408 100644 --- a/include/crypto/aead.h +++ b/include/crypto/aead.h @@ -1,11 +1,11 @@ /* * AEAD: Authenticated Encryption with Associated Data - * + * * Copyright (c) 2007 Herbert Xu * * 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) + * Software Foundation; either version 2 of the License, or (at your option) * any later version. * */ @@ -39,12 +39,24 @@ static inline struct crypto_aead *aead_givcrypt_reqtfm( static inline int crypto_aead_givencrypt(struct aead_givcrypt_request *req) { struct aead_tfm *crt = crypto_aead_crt(aead_givcrypt_reqtfm(req)); + +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return -EACCES; +#endif + return crt->givencrypt(req); }; static inline int crypto_aead_givdecrypt(struct aead_givcrypt_request *req) { struct aead_tfm *crt = crypto_aead_crt(aead_givcrypt_reqtfm(req)); + +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return -EACCES; +#endif + return crt->givdecrypt(req); }; @@ -59,6 +71,11 @@ static inline struct aead_givcrypt_request *aead_givcrypt_alloc( { struct aead_givcrypt_request *req; +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return NULL; +#endif + req = kmalloc(sizeof(struct aead_givcrypt_request) + crypto_aead_reqsize(tfm), gfp); diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h index 59c3e5b..1f40265 100644 --- a/include/crypto/algapi.h +++ b/include/crypto/algapi.h @@ -304,6 +304,7 @@ static inline void blkcipher_walk_init(struct blkcipher_walk *walk, walk->in.sg = src; walk->out.sg = dst; walk->total = nbytes; + walk->flags = 0; } static inline void ablkcipher_walk_init(struct ablkcipher_walk *walk, diff --git a/include/crypto/compress.h b/include/crypto/compress.h index 86163ef..607ba7d 100644 --- a/include/crypto/compress.h +++ b/include/crypto/compress.h @@ -99,46 +99,86 @@ static inline struct pcomp_alg *crypto_pcomp_alg(struct crypto_pcomp *tfm) static inline int crypto_compress_setup(struct crypto_pcomp *tfm, void *params, unsigned int len) { +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return -EACCES; +#endif + return crypto_pcomp_alg(tfm)->compress_setup(tfm, params, len); } static inline int crypto_compress_init(struct crypto_pcomp *tfm) { +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return -EACCES; +#endif + return crypto_pcomp_alg(tfm)->compress_init(tfm); } static inline int crypto_compress_update(struct crypto_pcomp *tfm, struct comp_request *req) { +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return -EACCES; +#endif + return crypto_pcomp_alg(tfm)->compress_update(tfm, req); } static inline int crypto_compress_final(struct crypto_pcomp *tfm, struct comp_request *req) { +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return -EACCES; +#endif + return crypto_pcomp_alg(tfm)->compress_final(tfm, req); } static inline int crypto_decompress_setup(struct crypto_pcomp *tfm, void *params, unsigned int len) { +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return -EACCES; +#endif + return crypto_pcomp_alg(tfm)->decompress_setup(tfm, params, len); } static inline int crypto_decompress_init(struct crypto_pcomp *tfm) { +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return -EACCES; +#endif + return crypto_pcomp_alg(tfm)->decompress_init(tfm); } static inline int crypto_decompress_update(struct crypto_pcomp *tfm, struct comp_request *req) { +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return -EACCES; +#endif + return crypto_pcomp_alg(tfm)->decompress_update(tfm, req); } static inline int crypto_decompress_final(struct crypto_pcomp *tfm, struct comp_request *req) { +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return -EACCES; +#endif + return crypto_pcomp_alg(tfm)->decompress_final(tfm, req); } diff --git a/include/crypto/hash.h b/include/crypto/hash.h index 26cb1eb..7029716 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -1,11 +1,11 @@ /* * Hash: Hash algorithms under the crypto API - * + * * Copyright (c) 2008 Herbert Xu * * 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) + * Software Foundation; either version 2 of the License, or (at your option) * any later version. * */ @@ -197,11 +197,21 @@ static inline int crypto_ahash_import(struct ahash_request *req, const void *in) static inline int crypto_ahash_init(struct ahash_request *req) { +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return -EACCES; +#endif + return crypto_ahash_reqtfm(req)->init(req); } static inline int crypto_ahash_update(struct ahash_request *req) { +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return -EACCES; +#endif + return crypto_ahash_reqtfm(req)->update(req); } @@ -216,6 +226,11 @@ static inline struct ahash_request *ahash_request_alloc( { struct ahash_request *req; +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return NULL; +#endif + req = kmalloc(sizeof(struct ahash_request) + crypto_ahash_reqsize(tfm), gfp); @@ -331,16 +346,31 @@ int crypto_shash_digest(struct shash_desc *desc, const u8 *data, static inline int crypto_shash_export(struct shash_desc *desc, void *out) { +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return -EACCES; +#endif + return crypto_shash_alg(desc->tfm)->export(desc, out); } static inline int crypto_shash_import(struct shash_desc *desc, const void *in) { +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return -EACCES; +#endif + return crypto_shash_alg(desc->tfm)->import(desc, in); } static inline int crypto_shash_init(struct shash_desc *desc) { +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return -EACCES; +#endif + return crypto_shash_alg(desc->tfm)->init(desc); } diff --git a/include/crypto/rng.h b/include/crypto/rng.h index c93f9b9..74db6da 100644 --- a/include/crypto/rng.h +++ b/include/crypto/rng.h @@ -58,6 +58,11 @@ static inline void crypto_free_rng(struct crypto_rng *tfm) static inline int crypto_rng_get_bytes(struct crypto_rng *tfm, u8 *rdata, unsigned int dlen) { +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return -EACCES; +#endif + return crypto_rng_crt(tfm)->rng_gen_random(tfm, rdata, dlen); } diff --git a/include/crypto/skcipher.h b/include/crypto/skcipher.h index 25fd612..c893e78 100644 --- a/include/crypto/skcipher.h +++ b/include/crypto/skcipher.h @@ -1,11 +1,11 @@ /* * Symmetric key ciphers. - * + * * Copyright (c) 2007 Herbert Xu * * 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) + * Software Foundation; either version 2 of the License, or (at your option) * any later version. * */ @@ -41,6 +41,10 @@ static inline int crypto_skcipher_givencrypt( { struct ablkcipher_tfm *crt = crypto_ablkcipher_crt(skcipher_givcrypt_reqtfm(req)); +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return -EACCES; +#endif return crt->givencrypt(req); }; @@ -49,6 +53,10 @@ static inline int crypto_skcipher_givdecrypt( { struct ablkcipher_tfm *crt = crypto_ablkcipher_crt(skcipher_givcrypt_reqtfm(req)); +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return -EACCES; +#endif return crt->givdecrypt(req); }; @@ -70,6 +78,11 @@ static inline struct skcipher_givcrypt_request *skcipher_givcrypt_alloc( { struct skcipher_givcrypt_request *req; +#ifdef CONFIG_CRYPTO_FIPS + if (unlikely(in_fips_err())) + return NULL; +#endif + req = kmalloc(sizeof(struct skcipher_givcrypt_request) + crypto_ablkcipher_reqsize(tfm), gfp); @@ -107,4 +120,3 @@ static inline void skcipher_givcrypt_set_giv( } #endif /* _CRYPTO_SKCIPHER_H */ - -- cgit v1.1