CRYPTO-C v1.1.3
C/C++ Documentation
sha3.cuh File Reference
#include "sha3.h"

Detailed Description

SHA3 CUDA hash function support.

This file is based on Dr. Markku-Juhani O. Saarinen's "cooked up" compact and readable keccak implemetation...

https://github.com/mjosaarinen/tiny_sha3

... which was released under the MIT license (MIT).

Alterations to the transform function were based on Marko Kreen's optimized C implementation...

https://github.com/markokr/spongeshaker

... which was released under the ISC License (ISC).

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

  • The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Functions

__device__ void cu_sha3_keccakf (uint64_t st[])
 SHA3_Keccak permutation rounds. More...
 
__device__ void cu_sha3_init (SHA3_KECCAK_CTX *ctx, int outlen)
 Initialize a SHA3 context. More...
 
__device__ void cu_keccak_init (SHA3_KECCAK_CTX *ctx, int outlen)
 Initialize a Keccak context. More...
 
__device__ void cu_sha3_update (SHA3_KECCAK_CTX *ctx, const void *in, size_t inlen)
 Add inlen bytes from in to a SHA3 context for hashing. More...
 
__device__ void cu_keccak_update (SHA3_KECCAK_CTX *ctx, const void *in, size_t inlen)
 Add inlen bytes from in to a Keccak context for hashing. More...
 
__device__ void cu_sha3_final (SHA3_KECCAK_CTX *ctx, void *out)
 Finalize a SHA3 message digest. More...
 
__device__ void cu_keccak_final (SHA3_KECCAK_CTX *ctx, void *out)
 Finalize a Keccak message digest. More...
 
__device__ void cu_sha3 (const void *in, size_t inlen, void *out, int outlen)
 Convenient all-in-one SHA3 computation. More...
 
__device__ void cu_keccak (const void *in, size_t inlen, void *out, int outlen)
 Convenient all-in-one Keccak computation. More...
 

Function Documentation

◆ cu_keccak()

__device__ void cu_keccak ( const void *  in,
size_t  inlen,
void *  out,
int  outlen 
)

Convenient all-in-one Keccak computation.

Performs keccak_init(), keccak_update() and keccak_final(), and places the resulting hash in out.

Parameters
inPointer to data to hash
inlenLength of in data, in bytes
outPointer to location to place the message digest
outlenLength* of desired message digest, in bytes
*compatible message digest lengths are 28, 32, 48 and 64

◆ cu_keccak_final()

__device__ void cu_keccak_final ( SHA3_KECCAK_CTX ctx,
void *  out 
)

Finalize a Keccak message digest.

Generate the Keccak message digest and place in out.

Parameters
ctxPointer to Keccak context
outPointer to location to place the message digest

◆ cu_keccak_init()

__device__ void cu_keccak_init ( SHA3_KECCAK_CTX ctx,
int  outlen 
)

Initialize a Keccak context.

Parameters
ctxPointer to Keccak context
outlenLength* of desired message digest, in bytes
*compatible message digest lengths are 28, 32, 48 and 64

◆ cu_keccak_update()

__device__ void cu_keccak_update ( SHA3_KECCAK_CTX ctx,
const void *  in,
size_t  inlen 
)

Add inlen bytes from in to a Keccak context for hashing.

Parameters
ctxPointer to Keccak context
inPointer to data to hash
inlenLength of in data, in bytes

◆ cu_sha3()

__device__ void cu_sha3 ( const void *  in,
size_t  inlen,
void *  out,
int  outlen 
)

Convenient all-in-one SHA3 computation.

Performs sha3_init(), sha3_update() and sha3_final(), and places the resulting hash in out.

Parameters
inPointer to data to hash
inlenLength of in data, in bytes
outPointer to location to place the message digest
outlenLength* of desired message digest, in bytes
*compatible message digest lengths are 28, 32, 48 and 64

◆ cu_sha3_final()

__device__ void cu_sha3_final ( SHA3_KECCAK_CTX ctx,
void *  out 
)

Finalize a SHA3 message digest.

Generate the SHA3 message digest and place in out.

Parameters
ctxPointer to SHA3 context
outPointer to location to place the message digest

◆ cu_sha3_init()

__device__ void cu_sha3_init ( SHA3_KECCAK_CTX ctx,
int  outlen 
)

Initialize a SHA3 context.

Parameters
ctxPointer to SHA3 context
outlenLength* of desired message digest, in bytes
*compatible message digest lengths are 28, 32, 48 and 64

◆ cu_sha3_keccakf()

__device__ void cu_sha3_keccakf ( uint64_t  st[])

SHA3_Keccak permutation rounds.

Parameters
stPointer to context state array

Keccakf round constant.

◆ cu_sha3_update()

__device__ void cu_sha3_update ( SHA3_KECCAK_CTX ctx,
const void *  in,
size_t  inlen 
)

Add inlen bytes from in to a SHA3 context for hashing.

Parameters
ctxPointer to SHA3 context
inPointer to data to hash
inlenLength of in data, in bytes