fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / arch / s390 / crypto / sha1_s390.c
index 98c896b..49ca869 100644 (file)
@@ -40,28 +40,29 @@ struct crypt_s390_sha1_ctx {
        u8 buffer[2 * SHA1_BLOCK_SIZE];
 };
 
-static void
-sha1_init(void *ctx)
+static void sha1_init(struct crypto_tfm *tfm)
 {
-       static const struct crypt_s390_sha1_ctx initstate = {
-               .state = {
-                       0x67452301,
-                       0xEFCDAB89,
-                       0x98BADCFE,
-                       0x10325476,
-                       0xC3D2E1F0
-               },
+       struct crypt_s390_sha1_ctx *ctx = crypto_tfm_ctx(tfm);
+       static const u32 initstate[5] = {
+               0x67452301,
+               0xEFCDAB89,
+               0x98BADCFE,
+               0x10325476,
+               0xC3D2E1F0
        };
-       memcpy(ctx, &initstate, sizeof(initstate));
+
+       ctx->count = 0;
+       memcpy(ctx->state, &initstate, sizeof(initstate));
+       ctx->buf_len = 0;
 }
 
-static void
-sha1_update(void *ctx, const u8 *data, unsigned int len)
+static void sha1_update(struct crypto_tfm *tfm, const u8 *data,
+                       unsigned int len)
 {
        struct crypt_s390_sha1_ctx *sctx;
        long imd_len;
 
-       sctx = ctx;
+       sctx = crypto_tfm_ctx(tfm);
        sctx->count += len * 8; //message bit length
 
        //anything in buffer yet? -> must be completed
@@ -110,10 +111,9 @@ pad_message(struct crypt_s390_sha1_ctx* sctx)
 }
 
 /* Add padding and return the message digest. */
-static void
-sha1_final(void* ctx, u8 *out)
+static void sha1_final(struct crypto_tfm *tfm, u8 *out)
 {
-       struct crypt_s390_sha1_ctx *sctx = ctx;
+       struct crypt_s390_sha1_ctx *sctx = crypto_tfm_ctx(tfm);
 
        //must perform manual padding
        pad_message(sctx);
@@ -126,6 +126,8 @@ sha1_final(void* ctx, u8 *out)
 
 static struct crypto_alg alg = {
        .cra_name       =       "sha1",
+       .cra_driver_name =      "sha1-s390",
+       .cra_priority   =       CRYPT_S390_PRIORITY,
        .cra_flags      =       CRYPTO_ALG_TYPE_DIGEST,
        .cra_blocksize  =       SHA1_BLOCK_SIZE,
        .cra_ctxsize    =       sizeof(struct crypt_s390_sha1_ctx),