OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
ChaCha.c File Reference
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/OcCryptoLib.h>

Go to the source code of this file.

Macros

#define U32V(v)
 
#define ROTATE(v, c)
 
#define XOR(v, w)
 
#define PLUS(v, w)
 
#define PLUSONE(v)
 
#define LOAD32_LE(a)
 
#define STORE32_LE(a, v)
 
#define QUARTERROUND(a, b, c, d)
 

Functions

VOID ChaChaInitCtx (OUT CHACHA_CONTEXT *Context, IN CONST UINT8 *Key, IN CONST UINT8 *Iv, IN UINT32 Counter)
 
VOID ChaChaCryptBuffer (IN OUT CHACHA_CONTEXT *Context, IN CONST UINT8 *Source, OUT UINT8 *Destination, IN UINT32 Length)
 

Detailed Description

OcCryptoLib

Copyright (c) 2020, vit9696

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 ChaCha.c.

Macro Definition Documentation

◆ LOAD32_LE

#define LOAD32_LE ( a)
Value:
(ReadUnaligned32 ((UINT32 *)(a)))
UINT32 EFIAPI ReadUnaligned32(IN CONST UINT32 *Buffer)

Definition at line 34 of file ChaCha.c.

◆ PLUS

#define PLUS ( v,
w )
Value:
(U32V((v) + (w)))
#define U32V(v)
Definition ChaCha.c:29

Definition at line 32 of file ChaCha.c.

◆ PLUSONE

#define PLUSONE ( v)
Value:
(PLUS((v), 1))
#define PLUS(v, w)
Definition ChaCha.c:32

Definition at line 33 of file ChaCha.c.

◆ QUARTERROUND

#define QUARTERROUND ( a,
b,
c,
d )
Value:
a = PLUS(a, b); \
d = ROTATE(XOR(d, a), 16); \
c = PLUS(c, d); \
b = ROTATE(XOR(b, c), 12); \
a = PLUS(a, b); \
d = ROTATE(XOR(d, a), 8); \
c = PLUS(c, d); \
b = ROTATE(XOR(b, c), 7);
#define ROTATE(v, c)
Definition ChaCha.c:30
#define XOR(v, w)
Definition ChaCha.c:31

Definition at line 37 of file ChaCha.c.

◆ ROTATE

#define ROTATE ( v,
c )
Value:
(LRotU32 ((v), (c)))

Definition at line 30 of file ChaCha.c.

◆ STORE32_LE

#define STORE32_LE ( a,
v )
Value:
(WriteUnaligned32 ((UINT32 *)(a), (v)))
UINT32 EFIAPI WriteUnaligned32(OUT UINT32 *Buffer, IN UINT32 Value)

Definition at line 35 of file ChaCha.c.

◆ U32V

#define U32V ( v)
Value:
((UINT32)(v) & 0xFFFFFFFFU)

Definition at line 29 of file ChaCha.c.

◆ XOR

#define XOR ( v,
w )
Value:
((v) ^ (w))

Definition at line 31 of file ChaCha.c.

Function Documentation

◆ ChaChaCryptBuffer()

VOID ChaChaCryptBuffer ( IN OUT CHACHA_CONTEXT * Context,
IN CONST UINT8 * Source,
OUT UINT8 * Destination,
IN UINT32 Length )

Perform ChaCha encryption/decryption. Source may match Destination.

Parameters
[in,out]ContextChaCha context.
[in]SourceData for transformation.
[out]DestinationResulting data.
[in]LengthData and ciphertext lengths.

Definition at line 74 of file ChaCha.c.

◆ ChaChaInitCtx()

VOID ChaChaInitCtx ( OUT CHACHA_CONTEXT * Context,
IN CONST UINT8 * Key,
IN CONST UINT8 * Iv,
IN UINT32 Counter )

Setup ChaCha context (IETF variant).

Parameters
[out]ContextChaCha context.
[in]KeyChaCha 256-bit key.
[in]IvChaCha 96-bit initialisation vector.
[in]CounterChaCha 32-bit counter.

Definition at line 48 of file ChaCha.c.