Loading...
Searching...
No Matches
XrdOucSHA3 Class Reference

`#include <XrdOucSHA3.hh>`

Collaboration diagram for XrdOucSHA3:

## Classes

struct | sha3_ctx_t
| SHA3 state context used by all methods (OpenSSL - like interface). More...
union | sha3_ctx_t.st

## Public Types

enum | MDLen { SHA3_128 = 16 , SHA3_224 = 28 , SHA3_256 = 32 , SHA3_384 = 48 , SHA3_512 = 64 }
| SHA3 digest lengths (bits to bytes). More...

## Public Member Functions

| XrdOucSHA3 ()
| ~XrdOucSHA3 ()

## Static Public Member Functions

static void * | Calc (const void *in, size_t inlen, void *md, MDLen mdlen)
static void | Final (sha3_ctx_t *c, void *md)
static void | Init (sha3_ctx_t *c, MDLen mdlen)
static void | SHAKE128_Init (sha3_ctx_t *c)
static void | SHAKE256_Init (sha3_ctx_t *c)
static void | SHAKE_Out (sha3_ctx_t *c, void *out, size_t len)
static void | SHAKE_Update (sha3_ctx_t *c, const void *data, size_t len)
static void | Update (sha3_ctx_t *c, const void *data, size_t len)

## Detailed Description

Definition at line 36 of file XrdOucSHA3.hh.

## Class Documentation

## XrdOucSHA3::sha3_ctx_t

struct XrdOucSHA3::sha3_ctx_t

SHA3 state context used by all methods (OpenSSL - like interface).

Definition at line 44 of file XrdOucSHA3.hh.

Collaboration diagram for XrdOucSHA3::sha3_ctx_t:

Class Members
int | mdlen |
int | pt |
int | rsiz |
union sha3_ctx_t.st | st |
int | xof | these don't overflow

## XrdOucSHA3::sha3_ctx_t.st

union XrdOucSHA3::sha3_ctx_t.st

Definition at line 45 of file XrdOucSHA3.hh.

Collaboration diagram for XrdOucSHA3::sha3_ctx_t.st:

Class Members
uint8_t | b[200] | < state: 8-bit bytes
uint64_t | q[25] | 64-bit words

## Member Enumeration Documentation

## MDLen

enum XrdOucSHA3::MDLen

SHA3 digest lengths (bits to bytes).

Enumerator
SHA3_128 |
SHA3_224 |
SHA3_256 |
SHA3_384 |
SHA3_512 |

Definition at line 56 of file XrdOucSHA3.hh.

{SHA3_128 = 16,
SHA3_224 = 28,
SHA3_256 = 32,
SHA3_384 = 48,
SHA3_512 = 64
};
XrdOucSHA3::SHA3_384
@ SHA3_384
Definition XrdOucSHA3.hh:59
XrdOucSHA3::SHA3_256
@ SHA3_256
Definition XrdOucSHA3.hh:58
XrdOucSHA3::SHA3_224
@ SHA3_224
Definition XrdOucSHA3.hh:57
XrdOucSHA3::SHA3_128
@ SHA3_128
Definition XrdOucSHA3.hh:56
XrdOucSHA3::SHA3_512
@ SHA3_512
Definition XrdOucSHA3.hh:60

## Constructor & Destructor Documentation

## XrdOucSHA3()

XrdOucSHA3::XrdOucSHA3 | ( |  | ) |

inline

Definition at line 143 of file XrdOucSHA3.hh.

{}

## ~XrdOucSHA3()

XrdOucSHA3::~XrdOucSHA3 | ( |  | ) |

inline

Definition at line 144 of file XrdOucSHA3.hh.

{}

## Member Function Documentation

## Calc()

void * XrdOucSHA3::Calc | ( | const void * | in,
|  | size_t | inlen,
|  | void * | md,
|  | XrdOucSHA3::MDLen | mdlen )

static

Compute a sha3 hash (md) of given byte length from "in" (one time call).

Parameters

  in | Pointer to input data.
  inlen | Length of data in bytes.
  md | Pointer to mbuffer of size SHA3_xxx to receive result.
  mdlen | Message digest byte length (one of the listed enums).

Returns
  Pointer to md.

Definition at line 150 of file XrdOucSHA3.cc.

{
sha3_ctx_t sha3;
Init(&sha3, mdlen);
Update(&sha3, in, inlen);
Final(&sha3, md);
return md;
}
XrdOucSHA3::Update
static void Update(sha3_ctx_t *c, const void *data, size_t len)
Definition XrdOucSHA3.cc:186
XrdOucSHA3::Init
static void Init(sha3_ctx_t *c, MDLen mdlen)
Definition XrdOucSHA3.cc:168
XrdOucSHA3::Final
static void Final(sha3_ctx_t *c, void *md)
Definition XrdOucSHA3.cc:208
XrdOucSHA3::sha3_ctx_t
SHA3 state context used by all methods (OpenSSL - like interface).
Definition XrdOucSHA3.hh:44

References Final(), Init(), and Update().

Here is the call graph for this function:

## Final()

void XrdOucSHA3::Final | ( | XrdOucSHA3::sha3_ctx_t * | c,
|  | void * | md )

static

Return final message digest.

Parameters

  c | Pointer to context.
  md | Pointer to buffer of size SHA3_xxx to receive result.

Definition at line 208 of file XrdOucSHA3.cc.

{
int i;
c->st.b[c->pt] ^= 0x06;
c->st.b[c->rsiz - 1] ^= 0x80;
sha3_keccakf(c->st.q);
for (i = 0; i < c->mdlen; i++) {
((uint8_t *) md)[i] = c->st.b[i];
}
}
XrdOucSHA3::sha3_ctx_t::mdlen
int mdlen
Definition XrdOucSHA3.hh:49
XrdOucSHA3::sha3_ctx_t::st
union XrdOucSHA3::sha3_ctx_t::@062310105257077056236306247365226352220233037115 st
XrdOucSHA3::sha3_ctx_t::pt
int pt
Definition XrdOucSHA3.hh:49
XrdOucSHA3::sha3_ctx_t::rsiz
int rsiz
Definition XrdOucSHA3.hh:49

References XrdOucSHA3::sha3_ctx_t::mdlen, XrdOucSHA3::sha3_ctx_t::pt, XrdOucSHA3::sha3_ctx_t::rsiz, and XrdOucSHA3::sha3_ctx_t::st.

Referenced by Calc().

Here is the caller graph for this function:

## Init()

void XrdOucSHA3::Init | ( | XrdOucSHA3::sha3_ctx_t * | c,
|  | XrdOucSHA3::MDLen | mdlen )

static

Initialize context in prepration for computing SHA3 checksum.

Parameters

  c | Pointer to context.
  mdlen | Message digest byte length (one of the listed enums).

Definition at line 168 of file XrdOucSHA3.cc.

{
int i;
for (i = 0; i < 25; i++)
c->st.q[i] = 0;
c->mdlen = (int)mdlen;
c->rsiz = 200 - 2 * (int)mdlen;
c->pt = 0;
c->xof= 1;
}
XrdOucSHA3::sha3_ctx_t::xof
int xof
these don't overflow
Definition XrdOucSHA3.hh:49

References XrdOucSHA3::sha3_ctx_t::mdlen, XrdOucSHA3::sha3_ctx_t::pt, XrdOucSHA3::sha3_ctx_t::rsiz, XrdOucSHA3::sha3_ctx_t::st, and XrdOucSHA3::sha3_ctx_t::xof.

Referenced by Calc(), SHAKE128_Init(), and SHAKE256_Init().

Here is the caller graph for this function:

## SHAKE128_Init()

void XrdOucSHA3::SHAKE128_Init | ( | sha3_ctx_t * | c | ) |

inline static

Initialize context to compute an extensible hash using a SHA3_128 digest.

Parameters

  c | Pointer to context.

Definition at line 110 of file XrdOucSHA3.hh.

{Init(c, SHA3_128);}

References Init(), and SHA3_128.

Here is the call graph for this function:

## SHAKE256_Init()

void XrdOucSHA3::SHAKE256_Init | ( | sha3_ctx_t * | c | ) |

inline static

Initialize context to compute an extensible hash using a SHA3_256 digest.

Parameters

  c | Pointer to context.

Definition at line 118 of file XrdOucSHA3.hh.

{Init(c, SHA3_256);}

References Init(), and SHA3_256.

Here is the call graph for this function:

## SHAKE_Out()

void XrdOucSHA3::SHAKE_Out | ( | XrdOucSHA3::sha3_ctx_t * | c,
|  | void * | out,
|  | size_t | len )

static

Return final message digest of desired length. This function may be called iteratively to get as many bits as needed. Bits beyound MDLen form a pseudo-random sequence (i.e. are repeatable with the same input).

Parameters

  c | Pointer to context.
  out | Pointer to buffer of size len to receive result.
  len | The number of digest bytes to return.

Definition at line 239 of file XrdOucSHA3.cc.

{
size_t i;
int j;
if (c->xof)
{shake_xof(c);
c->xof = 0;
}
j = c->pt;
for (i = 0; i < len; i++) {
if (j >= c->rsiz) {
sha3_keccakf(c->st.q);
j = 0;
}
((uint8_t *) out)[i] = c->st.b[j++];
}
c->pt = j;
}

References XrdOucSHA3::sha3_ctx_t::pt, XrdOucSHA3::sha3_ctx_t::rsiz, XrdOucSHA3::sha3_ctx_t::st, and XrdOucSHA3::sha3_ctx_t::xof.

## SHAKE_Update()

void XrdOucSHA3::SHAKE_Update | ( | sha3_ctx_t * | c,
|  | const void * | data,
|  | size_t | len )

inline static

Update shake digest with data.

Parameters

  c | Pointer to context.
  data | Pointer to data.
  len | Length of data in bytes.

Definition at line 128 of file XrdOucSHA3.hh.

{Update(c, data, len);}

References Update().

Here is the call graph for this function:

## Update()

void XrdOucSHA3::Update | ( | XrdOucSHA3::sha3_ctx_t * | c,
|  | const void * | data,
|  | size_t | len )

static

Update digest with data.

Parameters

  c | Pointer to context.
  data | Pointer to data.
  len | Length of data in bytes.

Definition at line 186 of file XrdOucSHA3.cc.

{
size_t i;
int j;
j = c->pt;
for (i = 0; i < len; i++) {
c->st.b[j++] ^= ((const uint8_t *) data)[i];
if (j >= c->rsiz) {
sha3_keccakf(c->st.q);
j = 0;
}
}
c->pt = j;
}

References XrdOucSHA3::sha3_ctx_t::pt, XrdOucSHA3::sha3_ctx_t::rsiz, and XrdOucSHA3::sha3_ctx_t::st.

Referenced by Calc(), and SHAKE_Update().

Here is the caller graph for this function:

The documentation for this class was generated from the following files:

- XrdOucSHA3.hh
- XrdOucSHA3.cc