Android-cuttlefish cvd tool
Classes | Macros | Functions | Variables
sha512.c File Reference
#include <assert.h>
#include <errno.h>
#include <getopt.h>
#include <dirent.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mntent.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <termios.h>
#include <unistd.h>
#include <signal.h>
#include <linux/fs.h>
Include dependency graph for sha512.c:

Classes

struct  sha512_state
 
struct  hash_state
 

Macros

#define F2FS_SHA512_LENGTH   64
 
#define CONST64(n)   n
 
#define Ch(x, y, z)   (z ^ (x & (y ^ z)))
 
#define Maj(x, y, z)   (((x | y) & z) | (x & y))
 
#define S(x, n)   ROR64c(x, n)
 
#define R(x, n)   (((x)&CONST64(0xFFFFFFFFFFFFFFFF))>>((__u64)n))
 
#define Sigma0(x)   (S(x, 28) ^ S(x, 34) ^ S(x, 39))
 
#define Sigma1(x)   (S(x, 14) ^ S(x, 18) ^ S(x, 41))
 
#define Gamma0(x)   (S(x, 1) ^ S(x, 8) ^ R(x, 7))
 
#define Gamma1(x)   (S(x, 19) ^ S(x, 61) ^ R(x, 6))
 
#define RND(a, b, c, d, e, f, g, h, i)
 
#define STORE64H(x, y)
 
#define LOAD64H(x, y)
 
#define ROR64c(x, y)
 
#define MIN(x, y)   ( ((x)<(y))?(x):(y) )
 
#define SHA512_BLOCKSIZE   128
 

Functions

static void sha512_compress (struct hash_state *md, const unsigned char *buf)
 
static void sha512_init (struct hash_state *md)
 
static void sha512_done (struct hash_state *md, unsigned char *out)
 
static void sha512_process (struct hash_state *md, const unsigned char *in, unsigned long inlen)
 
void f2fs_sha512 (const unsigned char *in, unsigned long in_size, unsigned char out[F2FS_SHA512_LENGTH])
 

Variables

static const __u64 K [80]
 

Macro Definition Documentation

◆ Ch

#define Ch (   x,
  y,
 
)    (z ^ (x & (y ^ z)))

◆ CONST64

#define CONST64 (   n)    n

◆ F2FS_SHA512_LENGTH

#define F2FS_SHA512_LENGTH   64

◆ Gamma0

#define Gamma0 (   x)    (S(x, 1) ^ S(x, 8) ^ R(x, 7))

◆ Gamma1

#define Gamma1 (   x)    (S(x, 19) ^ S(x, 61) ^ R(x, 6))

◆ LOAD64H

#define LOAD64H (   x,
 
)
Value:
do {x = \
(((__u64)((y)[0] & 255)) << 56) |\
(((__u64)((y)[1] & 255)) << 48) |\
(((__u64)((y)[2] & 255)) << 40) |\
(((__u64)((y)[3] & 255)) << 32) |\
(((__u64)((y)[4] & 255)) << 24) |\
(((__u64)((y)[5] & 255)) << 16) |\
(((__u64)((y)[6] & 255)) << 8) |\
(((__u64)((y)[7] & 255)));\
} while(0)
unsigned long long __u64
Definition: blkid_types.h:16
#define __u64
Definition: ext4_kernel_headers.h:33

◆ Maj

#define Maj (   x,
  y,
 
)    (((x | y) & z) | (x & y))

◆ MIN

#define MIN (   x,
 
)    ( ((x)<(y))?(x):(y) )

◆ R

#define R (   x,
 
)    (((x)&CONST64(0xFFFFFFFFFFFFFFFF))>>((__u64)n))

◆ RND

#define RND (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
 
)
Value:
t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i];\
t1 = Sigma0(a) + Maj(a, b, c);\
d += t0;\
h = t0 + t1;
struct f2fs_configuration c
Definition: libf2fs_io.c:47
#define Maj(x, y, z)
Definition: sha512.c:84
#define Sigma0(x)
Definition: sha512.c:87
#define Sigma1(x)
Definition: sha512.c:88
#define Ch(x, y, z)
Definition: sha512.c:83
static const __u64 K[80]
Definition: sha512.c:41

◆ ROR64c

#define ROR64c (   x,
 
)
Value:
( ((((x)&CONST64(0xFFFFFFFFFFFFFFFF))>>((__u64)(y)&CONST64(63))) | \
((x)<<((__u64)(64-((y)&CONST64(63)))))) & CONST64(0xFFFFFFFFFFFFFFFF))
#define CONST64(n)
Definition: sha512.c:40

◆ S

#define S (   x,
 
)    ROR64c(x, n)

◆ SHA512_BLOCKSIZE

#define SHA512_BLOCKSIZE   128

◆ Sigma0

#define Sigma0 (   x)    (S(x, 28) ^ S(x, 34) ^ S(x, 39))

◆ Sigma1

#define Sigma1 (   x)    (S(x, 14) ^ S(x, 18) ^ S(x, 41))

◆ STORE64H

#define STORE64H (   x,
 
)
Value:
do { \
(y)[0] = (unsigned char)(((x)>>56)&255);\
(y)[1] = (unsigned char)(((x)>>48)&255);\
(y)[2] = (unsigned char)(((x)>>40)&255);\
(y)[3] = (unsigned char)(((x)>>32)&255);\
(y)[4] = (unsigned char)(((x)>>24)&255);\
(y)[5] = (unsigned char)(((x)>>16)&255);\
(y)[6] = (unsigned char)(((x)>>8)&255);\
(y)[7] = (unsigned char)((x)&255); } while(0)

Function Documentation

◆ f2fs_sha512()

void f2fs_sha512 ( const unsigned char *  in,
unsigned long  in_size,
unsigned char  out[F2FS_SHA512_LENGTH] 
)

◆ sha512_compress()

static void sha512_compress ( struct hash_state md,
const unsigned char *  buf 
)
static

◆ sha512_done()

static void sha512_done ( struct hash_state md,
unsigned char *  out 
)
static

◆ sha512_init()

static void sha512_init ( struct hash_state md)
static

◆ sha512_process()

static void sha512_process ( struct hash_state md,
const unsigned char *  in,
unsigned long  inlen 
)
static

Variable Documentation

◆ K

const __u64 K[80]
static