Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

shw_hash.c File Reference


Detailed Description

This file contains implementations for use of the (internal) SHW hash software computation. It defines the usual three steps:

In support of the above functions, it also contains these functions:

These functions depend upon the Linux Endian functions __be32_to_cpu(), __cpu_to_be32() to convert a 4-byte big-endian array to an integer and vice-versa. For those without Linux, it should be pretty obvious what they do.

The shw_hash_update() and shw_hash_final() functions are generic enough to support SHA-1/SHA-224/SHA-256, as needed. Some extra tweaking would be necessary to get them to support SHA-384/SHA-512.

Definition in file shw_hash.c.

#include "shw_driver.h"
#include "shw_hash.h"
#include <asm/types.h>
#include <linux/byteorder/little_endian.h>

Go to the source code of this file.

Defines

#define a(i)   T[(0 - i) & 7]
#define b(i)   T[(1 - i) & 7]
#define blk0(i)   (W[i] = data[i])
#define blk2(i)   (W[i & 15] += s1(W[(i - 2) & 15]) + W[(i - 7) & 15] + s0(W[(i - 15) & 15]))
#define c(i)   T[(2 - i) & 7]
#define Ch(x, y, z)   (z ^ (x & (y ^ z)))
#define d(i)   T[(3 - i) & 7]
#define e(i)   T[(4 - i) & 7]
#define f(i)   T[(5 - i) & 7]
#define g(i)   T[(6 - i) & 7]
#define h(i)   T[(7 - i) & 7]
#define Maj(x, y, z)   ((x & y) | (z & (x | y)))
#define printk   printf
#define R(i)
#define s0(x)   (rotr32fixed(x, 7) ^ rotr32fixed(x, 18) ^ (x >> 3))
#define S0(x)   (rotr32fixed(x, 2) ^ rotr32fixed(x, 13) ^ rotr32fixed(x, 22))
#define s1(x)   (rotr32fixed(x, 17) ^ rotr32fixed(x, 19) ^ (x >> 10))
#define S1(x)   (rotr32fixed(x, 6) ^ rotr32fixed(x, 11) ^ rotr32fixed(x, 25))

Functions

uint32_t rotr32fixed (uint32_t x, unsigned int y)
void sha256_init (shw_hash_state_t *state)
static void sha256_process_block (shw_hash_state_t *state)
fsl_shw_return_t shw_hash_final (shw_hash_state_t *state, uint8_t *result, unsigned int result_len)
fsl_shw_return_t shw_hash_init (shw_hash_state_t *state, fsl_shw_hash_alg_t alg)
fsl_shw_return_t shw_hash_update (shw_hash_state_t *state, const uint8_t *input, unsigned int input_len)

Variables

const uint32_t K [64]


Generated by  Doxygen 1.6.0   Back to index