diff options
| author | Doug Zongker <dougz@android.com> | 2013-04-10 09:22:02 -0700 |
|---|---|---|
| committer | Doug Zongker <dougz@android.com> | 2013-04-10 14:33:31 -0700 |
| commit | 515e1639ef0ab5e3149fafeffce826cf654d616f (patch) | |
| tree | 2705b5fddfefbb667de7b4057ba1593864fb42e3 /include/mincrypt/hash-internal.h | |
| parent | 5cad7119761d3074497fbf33f2cd5854ae5c19d6 (diff) | |
| download | system_core-515e1639ef0ab5e3149fafeffce826cf654d616f.zip system_core-515e1639ef0ab5e3149fafeffce826cf654d616f.tar.gz system_core-515e1639ef0ab5e3149fafeffce826cf654d616f.tar.bz2 | |
mincrypt: support SHA-256 hash algorithm
- adds a library to compute the SHA-256 hash
- updates the RSA verifier to take an argument specifying either SHA-1
or SHA-256
- updates DumpPublicKey to with new "key" version numbers for
specifying SHA-256
- adds new argument to adb auth code to maintain existing behavior
Change-Id: I5b1406cf57c2b8993f6032eda3e29139f7740839
Diffstat (limited to 'include/mincrypt/hash-internal.h')
| -rw-r--r-- | include/mincrypt/hash-internal.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/include/mincrypt/hash-internal.h b/include/mincrypt/hash-internal.h new file mode 100644 index 0000000..96806f7 --- /dev/null +++ b/include/mincrypt/hash-internal.h @@ -0,0 +1,40 @@ +// Copyright 2007 Google Inc. All Rights Reserved. +// Author: mschilder@google.com (Marius Schilder) + +#ifndef SECURITY_UTIL_LITE_HASH_INTERNAL_H__ +#define SECURITY_UTIL_LITE_HASH_INTERNAL_H__ + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +struct HASH_CTX; // forward decl + +typedef struct HASH_VTAB { + void (* const init)(struct HASH_CTX*); + void (* const update)(struct HASH_CTX*, const void*, int); + const uint8_t* (* const final)(struct HASH_CTX*); + const uint8_t* (* const hash)(const void*, int, uint8_t*); + int size; +} HASH_VTAB; + +typedef struct HASH_CTX { + const HASH_VTAB * f; + uint64_t count; + uint8_t buf[64]; + uint32_t state[8]; // upto SHA2 +} HASH_CTX; + +#define HASH_init(ctx) (ctx)->f->init(ctx) +#define HASH_update(ctx, data, len) (ctx)->f->update(ctx, data, len) +#define HASH_final(ctx) (ctx)->f->final(ctx) +#define HASH_hash(data, len, digest) (ctx)->f->hash(data, len, digest) +#define HASH_size(ctx) (ctx)->f->size + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // SECURITY_UTIL_LITE_HASH_INTERNAL_H__ |
