Data Structures | Defines | Functions

# sha256.c File Reference

`#include "wizard/studio.h"`
`#include "wizard/exception.h"`
`#include "wizard/exception-private.h"`
`#include "wizard/memory_.h"`
`#include "wizard/sha256.h"`

## Data Structures
struct | _SHA256Info
## Defines
#define | SHA256Blocksize 64
#define | SHA256Digestsize 32
#define | Sigma0(x) (RotateRight(x,7) ^ RotateRight(x,18) ^ Trunc32((x) >> 3))
#define | Sigma1(x) (RotateRight(x,17) ^ RotateRight(x,19) ^ Trunc32((x) >> 10))
#define | Suma0(x) (RotateRight(x,2) ^ RotateRight(x,13) ^ RotateRight(x,22))
#define | Suma1(x) (RotateRight(x,6) ^ RotateRight(x,11) ^ RotateRight(x,25))
## Functions
static void | TransformSHA256 (SHA256Info *)
WizardExport SHA256Info * | AcquireSHA256Info (void)
WizardExport SHA256Info * | DestroySHA256Info (SHA256Info *sha_info)
WizardExport void | FinalizeSHA256 (SHA256Info *sha_info)
WizardExport unsigned int | GetSHA256Blocksize (const SHA256Info *sha256_info)
WizardExport const StringInfo * | GetSHA256Digest (const SHA256Info *sha256_info)
WizardExport unsigned int | GetSHA256Digestsize (const SHA256Info *sha256_info)
WizardExport void | InitializeSHA256 (SHA256Info *sha_info)
static unsigned int | Ch (unsigned int x, unsigned int y, unsigned int z)
static unsigned int | Maj (unsigned int x, unsigned int y, unsigned int z)
static unsigned int | Trunc32 (unsigned int x)
static unsigned int | RotateRight (unsigned int x, unsigned int n)
WizardExport void | UpdateSHA256 (SHA256Info *sha_info, const StringInfo *message)

## Define Documentation

#define SHA256Blocksize 64

Referenced by AcquireSHA256Info().

#define SHA256Digestsize 32

Referenced by AcquireSHA256Info(), and FinalizeSHA256().

#define Sigma0 | ( |  | x | ) | (RotateRight(x,7) ^ RotateRight(x,18) ^ Trunc32((x) >> 3))

#define Sigma1 | ( |  | x | ) | (RotateRight(x,17) ^ RotateRight(x,19) ^ Trunc32((x) >> 10))

#define Suma0 | ( |  | x | ) | (RotateRight(x,2) ^ RotateRight(x,13) ^ RotateRight(x,22))

#define Suma1 | ( |  | x | ) | (RotateRight(x,6) ^ RotateRight(x,11) ^ RotateRight(x,25))

## Function Documentation

WizardExport SHA256Info* AcquireSHA256Info | ( | void |  | ) |

References _SHA256Info::accumulator, AcquireQuantumMemory(), AcquireStringInfo(), AcquireWizardMemory(), _SHA256Info::blocksize, _SHA256Info::digest, _SHA256Info::digestsize, HashError, InitializeSHA256(), _SHA256Info::lsb_first, MemoryError, _SHA256Info::message, ResetWizardMemory(), SHA256Blocksize, SHA256Digestsize, _SHA256Info::signature, ThrowWizardFatalError, _SHA256Info::timestamp, WizardFalse, and WizardTrue.

Referenced by AcquireHashInfo().

static unsigned int Ch | ( | unsigned int | x,
|  | unsigned int | y,
|  | unsigned int | z |
| ) |  |  | `[inline, static]`

Referenced by TransformSHA256().

WizardExport SHA256Info* DestroySHA256Info | ( | SHA256Info * | sha_info | ) |

References _SHA256Info::accumulator, DestroyStringInfo(), _SHA256Info::digest, GetWizardModule, LogWizardEvent(), _SHA256Info::message, RelinquishWizardMemory(), _SHA256Info::signature, TraceEvent, and WizardSignature.

Referenced by DestroyHashInfo().

WizardExport void FinalizeSHA256 | ( | SHA256Info * | sha_info | ) |

References _SHA256Info::accumulator, _SHA256Info::digest, GetStringInfoDatum(), GetStringInfoLength(), GetWizardModule, _SHA256Info::high_order, LogWizardEvent(), _SHA256Info::low_order, _SHA256Info::message, ResetWizardMemory(), SHA256Digestsize, _SHA256Info::signature, TraceEvent, TransformSHA256(), and WizardSignature.

Referenced by FinalizeHash().

WizardExport unsigned int GetSHA256Blocksize | ( | const SHA256Info * | sha256_info | ) |

References _SHA256Info::blocksize, CipherDomain, GetWizardModule, LogWizardEvent(), _SHA256Info::signature, TraceEvent, WizardAssert, and WizardSignature.

Referenced by GetHashBlocksize().

WizardExport const StringInfo* GetSHA256Digest | ( | const SHA256Info * | sha256_info | ) |

References _SHA256Info::digest, GetWizardModule, HashDomain, LogWizardEvent(), _SHA256Info::signature, TraceEvent, WizardAssert, and WizardSignature.

Referenced by FinalizeHash().

WizardExport unsigned int GetSHA256Digestsize | ( | const SHA256Info * | sha256_info | ) |

References CipherDomain, _SHA256Info::digestsize, GetWizardModule, LogWizardEvent(), _SHA256Info::signature, TraceEvent, WizardAssert, and WizardSignature.

Referenced by AcquireHashInfo(), and GetHashDigestsize().

WizardExport void InitializeSHA256 | ( | SHA256Info * | sha_info | ) |

References _SHA256Info::accumulator, GetWizardModule, _SHA256Info::high_order, LogWizardEvent(), _SHA256Info::low_order, _SHA256Info::offset, _SHA256Info::signature, TraceEvent, and WizardSignature.

Referenced by AcquireSHA256Info(), and InitializeHash().

static unsigned int Maj | ( | unsigned int | x,
|  | unsigned int | y,
|  | unsigned int | z |
| ) |  |  | `[inline, static]`

Referenced by TransformSHA256().

static unsigned int RotateRight | ( | unsigned int | x,
|  | unsigned int | n |
| ) |  |  | `[static]`

References Trunc32().

static void TransformSHA256 | ( | SHA256Info * | sha_info | ) | `[static]`

References _SHA256Info::accumulator, Ch(), GetStringInfoDatum(), _SHA256Info::lsb_first, Maj(), _SHA256Info::message, ResetWizardMemory(), Sigma0, Sigma1, Suma0, Suma1, Trunc32(), and WizardFalse.

Referenced by FinalizeSHA256(), and UpdateSHA256().

static unsigned int Trunc32 | ( | unsigned int | x | ) | `[inline, static]`

Referenced by RotateRight(), TransformSHA256(), and UpdateSHA256().

WizardExport void UpdateSHA256 | ( | SHA256Info * | sha_info,
|  | const StringInfo * | message |
| ) |  |  |

References CopyWizardMemory(), GetStringInfoDatum(), GetStringInfoLength(), _SHA256Info::high_order, _SHA256Info::low_order, _SHA256Info::message, _SHA256Info::offset, SetStringInfoDatum(), _SHA256Info::signature, TransformSHA256(), Trunc32(), and WizardSignature.

Referenced by UpdateHash().