sha1_glue.c (1f8673d31a999ed7e20d9f66fcdad39e39f6b276) | sha1_glue.c (604682551aa511e00e57706ad5d9fcf955ee0323) |
---|---|
1/* 2 * Cryptographic API. 3 * Glue code for the SHA1 Secure Hash Algorithm assembler implementation 4 * 5 * This file is based on sha1_generic.c and sha1_ssse3_glue.c 6 * 7 * Copyright (c) Alan Smithee. 8 * Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk> --- 9 unchanged lines hidden (view full) --- 18 19#include <crypto/internal/hash.h> 20#include <linux/init.h> 21#include <linux/module.h> 22#include <linux/cryptohash.h> 23#include <linux/types.h> 24#include <crypto/sha.h> 25#include <asm/byteorder.h> | 1/* 2 * Cryptographic API. 3 * Glue code for the SHA1 Secure Hash Algorithm assembler implementation 4 * 5 * This file is based on sha1_generic.c and sha1_ssse3_glue.c 6 * 7 * Copyright (c) Alan Smithee. 8 * Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk> --- 9 unchanged lines hidden (view full) --- 18 19#include <crypto/internal/hash.h> 20#include <linux/init.h> 21#include <linux/module.h> 22#include <linux/cryptohash.h> 23#include <linux/types.h> 24#include <crypto/sha.h> 25#include <asm/byteorder.h> |
26#include <asm/crypto/sha1.h> |
|
26 27 28asmlinkage void sha1_block_data_order(u32 *digest, 29 const unsigned char *data, unsigned int rounds); 30 31 32static int sha1_init(struct shash_desc *desc) 33{ --- 26 unchanged lines hidden (view full) --- 60 done += rounds * SHA1_BLOCK_SIZE; 61 } 62 63 memcpy(sctx->buffer, data + done, len - done); 64 return 0; 65} 66 67 | 27 28 29asmlinkage void sha1_block_data_order(u32 *digest, 30 const unsigned char *data, unsigned int rounds); 31 32 33static int sha1_init(struct shash_desc *desc) 34{ --- 26 unchanged lines hidden (view full) --- 61 done += rounds * SHA1_BLOCK_SIZE; 62 } 63 64 memcpy(sctx->buffer, data + done, len - done); 65 return 0; 66} 67 68 |
68static int sha1_update(struct shash_desc *desc, const u8 *data, 69 unsigned int len) | 69int sha1_update_arm(struct shash_desc *desc, const u8 *data, 70 unsigned int len) |
70{ 71 struct sha1_state *sctx = shash_desc_ctx(desc); 72 unsigned int partial = sctx->count % SHA1_BLOCK_SIZE; 73 int res; 74 75 /* Handle the fast case right here */ 76 if (partial + len < SHA1_BLOCK_SIZE) { 77 sctx->count += len; 78 memcpy(sctx->buffer + partial, data, len); 79 return 0; 80 } 81 res = __sha1_update(sctx, data, len, partial); 82 return res; 83} | 71{ 72 struct sha1_state *sctx = shash_desc_ctx(desc); 73 unsigned int partial = sctx->count % SHA1_BLOCK_SIZE; 74 int res; 75 76 /* Handle the fast case right here */ 77 if (partial + len < SHA1_BLOCK_SIZE) { 78 sctx->count += len; 79 memcpy(sctx->buffer + partial, data, len); 80 return 0; 81 } 82 res = __sha1_update(sctx, data, len, partial); 83 return res; 84} |
85EXPORT_SYMBOL_GPL(sha1_update_arm); |
|
84 85 86/* Add padding and return the message digest. */ 87static int sha1_final(struct shash_desc *desc, u8 *out) 88{ 89 struct sha1_state *sctx = shash_desc_ctx(desc); 90 unsigned int i, index, padlen; 91 __be32 *dst = (__be32 *)out; --- 38 unchanged lines hidden (view full) --- 130 memcpy(sctx, in, sizeof(*sctx)); 131 return 0; 132} 133 134 135static struct shash_alg alg = { 136 .digestsize = SHA1_DIGEST_SIZE, 137 .init = sha1_init, | 86 87 88/* Add padding and return the message digest. */ 89static int sha1_final(struct shash_desc *desc, u8 *out) 90{ 91 struct sha1_state *sctx = shash_desc_ctx(desc); 92 unsigned int i, index, padlen; 93 __be32 *dst = (__be32 *)out; --- 38 unchanged lines hidden (view full) --- 132 memcpy(sctx, in, sizeof(*sctx)); 133 return 0; 134} 135 136 137static struct shash_alg alg = { 138 .digestsize = SHA1_DIGEST_SIZE, 139 .init = sha1_init, |
138 .update = sha1_update, | 140 .update = sha1_update_arm, |
139 .final = sha1_final, 140 .export = sha1_export, 141 .import = sha1_import, 142 .descsize = sizeof(struct sha1_state), 143 .statesize = sizeof(struct sha1_state), 144 .base = { 145 .cra_name = "sha1", 146 .cra_driver_name= "sha1-asm", --- 27 unchanged lines hidden --- | 141 .final = sha1_final, 142 .export = sha1_export, 143 .import = sha1_import, 144 .descsize = sizeof(struct sha1_state), 145 .statesize = sizeof(struct sha1_state), 146 .base = { 147 .cra_name = "sha1", 148 .cra_driver_name= "sha1-asm", --- 27 unchanged lines hidden --- |