12.2. sha1 — SHA1

Source code: src/hash/sha1.h, src/hash/sha1.c

Test code: tst/hash/main.c

Test coverage: src/hash/sha1.c


Functions

int sha1_init(struct sha1_t *self_p)

Initialize given SHA1 object.

Return
zero(0) or negative error code.
Parameters
  • self_p -

    SHA1 object.

int sha1_update(struct sha1_t *self_p, void *buf_p, size_t size)

Update the sha object with the given buffer. Repeated calls are equivalent to a single call with the concatenation of all the arguments.

Return
zero(0) or negative error code.
Parameters
  • self_p -

    SHA1 object.

  • buf_p -

    Buffer to update the sha object with.

  • size -

    Size of the buffer.

int sha1_digest(struct sha1_t *self_p, uint8_t *hash_p)

Return the digest of the strings passed to the sha1_update() method so far. This is a 20-byte value which may contain non-ASCII characters, including null bytes.

Return
zero(0) or negative error code.
Parameters
  • self_p -

    SHA1 object.

  • hash_p -

    Hash sum.

struct sha1_t

Public Members

uint8_t buf[64]
uint32_t size
struct sha1_t::@32 sha1_t::block
uint32_t h[5]
uint64_t size