Ruby: siphash.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Macros | Functions
siphash.c File Reference
`#include <string.h>`
`#include <stdio.h>`
`#include "siphash.h"`

Go to the source code of this file.

## Macros
#define | lo u32[0]
#define | hi u32[1]
#define | UNALIGNED_WORD_ACCESS 0
#define | U8TO32_LE(p)
#define | U32TO8_LE(p, v)
#define | U8TO64_LE(p) u8to64_le(p)
#define | U64TO8_LE(p, v) u64to8_le(p, v)
#define | ROTL64_TO(v, s)
#define | ADD64_TO(v, s) add64_to(&(v), (s))
#define | XOR64_TO(v, s) xor64_to(&(v), (s))
#define | XOR64_INT(v, x) ((v).lo ^= (x))
#define | sip_init_state sip_init_state_bin.u64
#define | SIP_COMPRESS(v0, v1, v2, v3)
#define | SIP_ROUND(m, v0, v1, v2, v3)
#define | OR_BYTE(n)

## Functions
uint64_t | sip_hash13 (const uint8_t key[16], const uint8_t *data, size_t len)

## Macro Definition Documentation

## ◆ ADD64_TO

#define ADD64_TO | ( |  | v,
|  |  | s
| ) |  | add64_to(&(v), (s))

Definition at line 112 of file siphash.c.

## ◆ hi

#define hi u32[1]

Definition at line 22 of file siphash.c.

## ◆ lo

#define lo u32[0]

Definition at line 21 of file siphash.c.

## ◆ OR_BYTE

#define OR_BYTE | ( |  | n | ) |

Value:
do { \
if (n >= 4) \
last.hi |= ((uint32_t) end[n]) << ((n) >= 4 ? (n) * 8 - 32 : 0); \
else \
last.lo |= ((uint32_t) end[n]) << ((n) >= 4 ? 0 : (n) * 8); \
} while (0)
last
unsigned int last
Definition: nkf.c:4324
uint32_t
unsigned int uint32_t
Definition: sha2.h:101

## ◆ ROTL64_TO

#define ROTL64_TO | ( |  | v,
|  |  | s
| ) |  |

Value:
((s) > 32 ? rotl64_swap(rotl64_to(&(v), (s) - 32)) : \
(s) == 32 ? rotl64_swap(&(v)) : rotl64_to(&(v), (s)))

Definition at line 91 of file siphash.c.

## ◆ SIP_COMPRESS

#define SIP_COMPRESS | ( |  | v0,
|  |  | v1,
|  |  | v2,
|  |  | v3
| ) |  |

Value:
do { \
ADD64_TO((v0), (v1)); \
ADD64_TO((v2), (v3)); \
ROTL64_TO((v1), 13); \
ROTL64_TO((v3), 16); \
XOR64_TO((v1), (v0)); \
XOR64_TO((v3), (v2)); \
ROTL64_TO((v0), 32); \
ADD64_TO((v2), (v1)); \
ADD64_TO((v0), (v3)); \
ROTL64_TO((v1), 17); \
ROTL64_TO((v3), 21); \
XOR64_TO((v1), (v2)); \
XOR64_TO((v3), (v0)); \
ROTL64_TO((v2), 32); \
} while(0)

Definition at line 158 of file siphash.c.

## ◆ sip_init_state

#define sip_init_state sip_init_state_bin.u64

Definition at line 138 of file siphash.c.

## ◆ SIP_ROUND

#define SIP_ROUND | ( |  | m,
|  |  | v0,
|  |  | v1,
|  |  | v2,
|  |  | v3
| ) |  |

Value:
do { \
XOR64_TO((v3), (m)); \
SIP_COMPRESS(v0, v1, v2, v3); \
XOR64_TO((v0), (m)); \
} while (0)

Definition at line 389 of file siphash.c.

## ◆ U32TO8_LE

#define U32TO8_LE | ( |  | p,
|  |  | v
| ) |  |

Value:
do { \
(p)[0] = (uint8_t)((v) ); \
(p)[1] = (uint8_t)((v) >> 8); \
(p)[2] = (uint8_t)((v) >> 16); \
(p)[3] = (uint8_t)((v) >> 24); \
} while (0)
uint8_t
unsigned char uint8_t
Definition: sha2.h:100

Definition at line 46 of file siphash.c.

## ◆ U64TO8_LE

#define U64TO8_LE | ( |  | p,
|  |  | v
| ) |  | u64to8_le(p, v)

Definition at line 83 of file siphash.c.

## ◆ U8TO32_LE

#define U8TO32_LE | ( |  | p | ) |

Value:
(((uint32_t)((p)[0]) ) | ((uint32_t)((p)[1]) << 8) | \
((uint32_t)((p)[2]) << 16) | ((uint32_t)((p)[3]) << 24)) \

Definition at line 42 of file siphash.c.

## ◆ U8TO64_LE

#define U8TO64_LE | ( |  | p | ) | u8to64_le(p)

Definition at line 73 of file siphash.c.

## ◆ UNALIGNED_WORD_ACCESS

#define UNALIGNED_WORD_ACCESS 0

Definition at line 39 of file siphash.c.

## ◆ XOR64_INT

#define XOR64_INT | ( |  | v,
|  |  | x
| ) |  | ((v).lo ^= (x))

Definition at line 131 of file siphash.c.

## ◆ XOR64_TO

#define XOR64_TO | ( |  | v,
|  |  | s
| ) |  | xor64_to(&(v), (s))

Definition at line 122 of file siphash.c.

## Function Documentation

## ◆ sip_hash13()

uint64_t sip_hash13 | ( | const uint8_t | key[16],
|  | const uint8_t * | data,
|  | size_t | len
| ) |  |

Definition at line 397 of file siphash.c.

References key, last, len, OR_BYTE, SIP_COMPRESS, sip_init_state, SIP_ROUND, U8TO64_LE, uint64_t, XOR64_INT, and XOR64_TO.

## Variable Documentation

## ◆ bin

char bin[32]

Definition at line 135 of file siphash.c.

## ◆ u64

uint64_t u64[4]

Definition at line 136 of file siphash.c.

Referenced by ffi_closure_tile_inner().