X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=crypto%2Finternal.h;h=37aa652ce5ce6f89e4738ac07dd770b8df4a6ac9;hb=9317259ead88fe6c05120ae1e3ace99738e2c698;hp=83b1b6d6d92b9963d392dc9ea11c3f5eaa1c9ea9;hpb=176c3652c544b6f8d4bb1984c58c10080f45dbf0;p=linux-2.6 diff --git a/crypto/internal.h b/crypto/internal.h index 83b1b6d6d9..37aa652ce5 100644 --- a/crypto/internal.h +++ b/crypto/internal.h @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include extern enum km_type crypto_km_types[]; @@ -37,7 +39,7 @@ static inline void crypto_kunmap(void *vaddr, int out) static inline void crypto_yield(struct crypto_tfm *tfm) { - if (!in_atomic()) + if (tfm->crt_flags & CRYPTO_TFM_REQ_MAY_SLEEP) cond_resched(); } @@ -61,6 +63,33 @@ static inline void crypto_init_proc(void) { } #endif +static inline unsigned int crypto_digest_ctxsize(struct crypto_alg *alg, + int flags) +{ + return alg->cra_ctxsize; +} + +static inline unsigned int crypto_cipher_ctxsize(struct crypto_alg *alg, + int flags) +{ + unsigned int len = alg->cra_ctxsize; + + switch (flags & CRYPTO_TFM_MODE_MASK) { + case CRYPTO_TFM_MODE_CBC: + len = ALIGN(len, (unsigned long)alg->cra_alignmask + 1); + len += alg->cra_blocksize; + break; + } + + return len; +} + +static inline unsigned int crypto_compress_ctxsize(struct crypto_alg *alg, + int flags) +{ + return alg->cra_ctxsize; +} + int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags); int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags); int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags);