|
UFO: Alien Invasion
|
#include <string.h>#include <stdio.h>#include "sha2.h"#include "filesys.h"#include "../shared/shared.h"
Go to the source code of this file.
Macros | |
| #define | _CRT_SECURE_NO_DEPRECATE 1 |
| #define | GET_UINT32_BE(n, b, i) |
| #define | PUT_UINT32_BE(n, b, i) |
| #define | SHR(x, n) ((x & 0xFFFFFFFF) >> n) |
| #define | ROTR(x, n) (SHR(x,n) | (x << (32 - n))) |
| #define | S0(x) (ROTR(x, 7) ^ ROTR(x,18) ^ SHR(x, 3)) |
| #define | S1(x) (ROTR(x,17) ^ ROTR(x,19) ^ SHR(x,10)) |
| #define | S2(x) (ROTR(x, 2) ^ ROTR(x,13) ^ ROTR(x,22)) |
| #define | S3(x) (ROTR(x, 6) ^ ROTR(x,11) ^ ROTR(x,25)) |
| #define | F0(x, y, z) ((x & y) | (z & (x | y))) |
| #define | F1(x, y, z) (z ^ (x & (y ^ z))) |
| #define | R(t) |
| #define | P(a, b, c, d, e, f, g, h, x, K) |
Functions | |
| void | Com_SHA2Starts (sha2_context *ctx) |
| static void | Com_SHA2Process (sha2_context *ctx, const byte data[64]) |
| void | Com_SHA2Update (sha2_context *ctx, const byte *input, uint32_t length) |
| void | Com_SHA2Finish (sha2_context *ctx, byte digest[32]) |
| bool | Com_SHA2File (const char *filename, byte digest[32]) |
| Output SHA-256(file contents) More... | |
| void | Com_SHA2Csum (const byte *buf, uint32_t buflen, byte digest[32]) |
| Output SHA-256(buf) More... | |
| void | Com_SHA2ToHex (const byte digest[32], char final[65]) |
| void | Com_SHA2Hmac (const byte *buf, uint32_t buflen, const byte *key, uint32_t keylen, byte digest[32]) |
| Output HMAC-SHA-256(buf,key) More... | |
Variables | |
| static const byte | sha2_padding [64] |
| #define F0 | ( | x, | |
| y, | |||
| z | |||
| ) | ((x & y) | (z & (x | y))) |
| #define F1 | ( | x, | |
| y, | |||
| z | |||
| ) | (z ^ (x & (y ^ z))) |
| #define GET_UINT32_BE | ( | n, | |
| b, | |||
| i | |||
| ) |
| #define P | ( | a, | |
| b, | |||
| c, | |||
| d, | |||
| e, | |||
| f, | |||
| g, | |||
| h, | |||
| x, | |||
| K | |||
| ) |
| #define PUT_UINT32_BE | ( | n, | |
| b, | |||
| i | |||
| ) |
| #define R | ( | t | ) |
| #define ROTR | ( | x, | |
| n | |||
| ) | (SHR(x,n) | (x << (32 - n))) |
| #define SHR | ( | x, | |
| n | |||
| ) | ((x & 0xFFFFFFFF) >> n) |
Output SHA-256(buf)
Definition at line 292 of file sha2.cpp.
References Com_SHA2Finish(), Com_SHA2Starts(), and Com_SHA2Update().
Referenced by TEST_F().
| bool Com_SHA2File | ( | const char * | filename, |
| byte | digest[32] | ||
| ) |
Output SHA-256(file contents)
true if successful Definition at line 270 of file sha2.cpp.
References Com_SHA2Finish(), Com_SHA2Starts(), Com_SHA2Update(), f, FILE_READ, FS_OpenFile(), and FS_Read().
| void Com_SHA2Finish | ( | sha2_context * | ctx, |
| byte | digest[32] | ||
| ) |
Definition at line 244 of file sha2.cpp.
References Com_SHA2Update(), PUT_UINT32_BE, sha2_padding, sha2_context::state, and sha2_context::total.
Referenced by Com_SHA2Csum(), Com_SHA2File(), and Com_SHA2Hmac().
| void Com_SHA2Hmac | ( | const byte * | buf, |
| uint32_t | buflen, | ||
| const byte * | key, | ||
| uint32_t | keylen, | ||
| byte | digest[32] | ||
| ) |
Output HMAC-SHA-256(buf,key)
Definition at line 308 of file sha2.cpp.
References Com_SHA2Finish(), Com_SHA2Starts(), Com_SHA2Update(), i, and key.
|
static |
Definition at line 77 of file sha2.cpp.
References data, E, F, G, GET_UINT32_BE, H, P, R, and sha2_context::state.
Referenced by Com_SHA2Update().
| void Com_SHA2Starts | ( | sha2_context * | ctx | ) |
Core SHA-256 functions
Definition at line 62 of file sha2.cpp.
References sha2_context::state, and sha2_context::total.
Referenced by Com_SHA2Csum(), Com_SHA2File(), and Com_SHA2Hmac().
| void Com_SHA2Update | ( | sha2_context * | ctx, |
| const byte * | input, | ||
| uint32_t | length | ||
| ) |
Definition at line 207 of file sha2.cpp.
References sha2_context::buffer, Com_SHA2Process(), length, and sha2_context::total.
Referenced by Com_SHA2Csum(), Com_SHA2File(), Com_SHA2Finish(), and Com_SHA2Hmac().
|
static |
Definition at line 240 of file sha2.cpp.
Referenced by Com_SHA2Finish().