OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
Sha2.c File Reference
#include "Sha2Internal.h"

Go to the source code of this file.

Macros

#define UNPACK64(x, str)
 
#define PACK64(str, x)
 
#define SHFR(a, b)
 
#define ROTLEFT(a, b)
 
#define ROTRIGHT(a, b)
 
#define CH(x, y, z)
 
#define MAJ(x, y, z)
 
#define SHA256_EP0(x)
 
#define SHA256_EP1(x)
 
#define SHA256_SIG0(x)
 
#define SHA256_SIG1(x)
 
#define SHA512_EP0(x)
 
#define SHA512_EP1(x)
 
#define SHA512_SIG0(x)
 
#define SHA512_SIG1(x)
 
#define SHA512_SCR(Index)
 

Variables

GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN mIsAccelEnabled
 

Detailed Description

OcCryptoLib

Copyright (c) 2018, savvas

All rights reserved.

This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Definition in file Sha2.c.

Macro Definition Documentation

◆ CH

#define CH ( x,
y,
z )
Value:
(((x) & (y)) ^ (~(x) & (z)))
UINT16 y
Definition BmfFile.h:84
UINT16 x
Definition BmfFile.h:83

Definition at line 62 of file Sha2.c.

◆ MAJ

#define MAJ ( x,
y,
z )
Value:
(((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))

Definition at line 63 of file Sha2.c.

◆ PACK64

#define PACK64 ( str,
x )
Value:
do { \
*(x) = ((UINT64) *((str) + 7)) \
| LShiftU64 (*((str) + 6), 8) \
| LShiftU64 (*((str) + 5), 16) \
| LShiftU64 (*((str) + 4), 24) \
| LShiftU64 (*((str) + 3), 32) \
| LShiftU64 (*((str) + 2), 40) \
| LShiftU64 (*((str) + 1), 48) \
| LShiftU64 (*((str) + 0), 56); \
} while (0)
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
Definition UserMath.c:76

Definition at line 47 of file Sha2.c.

◆ ROTLEFT

#define ROTLEFT ( a,
b )
Value:
((a << b) | (a >> ((sizeof(a) << 3) - b)))

Definition at line 60 of file Sha2.c.

◆ ROTRIGHT

#define ROTRIGHT ( a,
b )
Value:
((a >> b) | (a << ((sizeof(a) << 3) - b)))

Definition at line 61 of file Sha2.c.

◆ SHA256_EP0

#define SHA256_EP0 ( x)
Value:
(ROTRIGHT(x, 2) ^ ROTRIGHT(x, 13) ^ ROTRIGHT(x, 22))
#define ROTRIGHT(a, b)
Definition Sha2.c:61

Definition at line 68 of file Sha2.c.

◆ SHA256_EP1

#define SHA256_EP1 ( x)
Value:
(ROTRIGHT(x, 6) ^ ROTRIGHT(x, 11) ^ ROTRIGHT(x, 25))

Definition at line 69 of file Sha2.c.

◆ SHA256_SIG0

#define SHA256_SIG0 ( x)
Value:
(ROTRIGHT(x, 7) ^ ROTRIGHT(x, 18) ^ SHFR(x, 3))
#define SHFR(a, b)
Definition Sha2.c:59

Definition at line 70 of file Sha2.c.

◆ SHA256_SIG1

#define SHA256_SIG1 ( x)
Value:
(ROTRIGHT(x, 17) ^ ROTRIGHT(x, 19) ^ SHFR(x, 10))

Definition at line 71 of file Sha2.c.

◆ SHA512_EP0

#define SHA512_EP0 ( x)
Value:
(ROTRIGHT(x, 28) ^ ROTRIGHT(x, 34) ^ ROTRIGHT(x, 39))

Definition at line 76 of file Sha2.c.

◆ SHA512_EP1

#define SHA512_EP1 ( x)
Value:
(ROTRIGHT(x, 14) ^ ROTRIGHT(x, 18) ^ ROTRIGHT(x, 41))

Definition at line 77 of file Sha2.c.

◆ SHA512_SCR

#define SHA512_SCR ( Index)
Value:
do { \
W[Index] = SHA512_SIG1(W[Index - 2]) + W[Index - 7] \
+ SHA512_SIG0(W[Index - 15]) + W[Index - 16]; \
} while(0)
#define SHA512_SIG0(x)
Definition Sha2.c:78
#define SHA512_SIG1(x)
Definition Sha2.c:79
#define W
Definition crc32.c:85

Definition at line 81 of file Sha2.c.

◆ SHA512_SIG0

#define SHA512_SIG0 ( x)
Value:
(ROTRIGHT(x, 1) ^ ROTRIGHT(x, 8) ^ SHFR(x, 7))

Definition at line 78 of file Sha2.c.

◆ SHA512_SIG1

#define SHA512_SIG1 ( x)
Value:
(ROTRIGHT(x, 19) ^ ROTRIGHT(x, 61) ^ SHFR(x, 6))

Definition at line 79 of file Sha2.c.

◆ SHFR

#define SHFR ( a,
b )
Value:
(a >> b)

Definition at line 59 of file Sha2.c.

◆ UNPACK64

#define UNPACK64 ( x,
str )
Value:
do { \
*((str) + 7) = (UINT8) (x); \
*((str) + 6) = (UINT8) RShiftU64 ((x), 8); \
*((str) + 5) = (UINT8) RShiftU64 ((x), 16); \
*((str) + 4) = (UINT8) RShiftU64 ((x), 24); \
*((str) + 3) = (UINT8) RShiftU64 ((x), 32); \
*((str) + 2) = (UINT8) RShiftU64 ((x), 40); \
*((str) + 1) = (UINT8) RShiftU64 ((x), 48); \
*((str) + 0) = (UINT8) RShiftU64 ((x), 56); \
} while(0)
UINT64 EFIAPI RShiftU64(IN UINT64 Operand, IN UINTN Count)
Definition UserMath.c:86

Filename: sha256.c Author: Brad Conte (brad AT bradconte.com) Copyright: Disclaimer: This code is presented "as is" without any guarantees. Details: Implementation of the SHA-256 hashing algorithm. SHA-256 is one of the three algorithms in the SHA2 specification. The others, SHA-384 and SHA-512, are not offered in this implementation. Algorithm specification can be found here: http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf This implementation uses little endian byte order.

Definition at line 35 of file Sha2.c.

Variable Documentation

◆ mIsAccelEnabled

GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN mIsAccelEnabled

Definition at line 87 of file Sha2.c.