Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/lib/crypto/mips/md5.h
29278 views
1
/*
2
* Cryptographic API.
3
*
4
* MD5 Message Digest Algorithm (RFC1321).
5
*
6
* Adapted for OCTEON by Aaro Koskinen <[email protected]>.
7
*
8
* Based on crypto/md5.c, which is:
9
*
10
* Derived from cryptoapi implementation, originally based on the
11
* public domain implementation written by Colin Plumb in 1993.
12
*
13
* Copyright (c) Cryptoapi developers.
14
* Copyright (c) 2002 James Morris <[email protected]>
15
*
16
* This program is free software; you can redistribute it and/or modify it
17
* under the terms of the GNU General Public License as published by the Free
18
* Software Foundation; either version 2 of the License, or (at your option)
19
* any later version.
20
*/
21
22
#include <asm/octeon/crypto.h>
23
#include <asm/octeon/octeon.h>
24
25
/*
26
* We pass everything as 64-bit. OCTEON can handle misaligned data.
27
*/
28
29
static void md5_blocks(struct md5_block_state *state,
30
const u8 *data, size_t nblocks)
31
{
32
struct octeon_cop2_state cop2_state;
33
u64 *state64 = (u64 *)state;
34
unsigned long flags;
35
36
if (!octeon_has_crypto())
37
return md5_blocks_generic(state, data, nblocks);
38
39
cpu_to_le32_array(state->h, ARRAY_SIZE(state->h));
40
41
flags = octeon_crypto_enable(&cop2_state);
42
write_octeon_64bit_hash_dword(state64[0], 0);
43
write_octeon_64bit_hash_dword(state64[1], 1);
44
45
do {
46
const u64 *block = (const u64 *)data;
47
48
write_octeon_64bit_block_dword(block[0], 0);
49
write_octeon_64bit_block_dword(block[1], 1);
50
write_octeon_64bit_block_dword(block[2], 2);
51
write_octeon_64bit_block_dword(block[3], 3);
52
write_octeon_64bit_block_dword(block[4], 4);
53
write_octeon_64bit_block_dword(block[5], 5);
54
write_octeon_64bit_block_dword(block[6], 6);
55
octeon_md5_start(block[7]);
56
57
data += MD5_BLOCK_SIZE;
58
} while (--nblocks);
59
60
state64[0] = read_octeon_64bit_hash_dword(0);
61
state64[1] = read_octeon_64bit_hash_dword(1);
62
octeon_crypto_disable(&cop2_state, flags);
63
64
le32_to_cpu_array(state->h, ARRAY_SIZE(state->h));
65
}
66
67