| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* sl_sha2.h :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: bchanot <bchanot@student.42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2018/09/26 20:13:19 by bchanot #+# #+# */
- /* Updated: 2018/10/10 12:55:47 by bchanot ### ########.fr */
- /* */
- /* ************************************************************************** */
- #ifndef SL_SHA2_H
- # define SL_SHA2_H
- # define EP0_SHA2(x) (ROR32(x, 2) ^ ROR32(x, 13) ^ ROR32(x, 22))
- # define EP1_SHA2(x) (ROR32(x, 6) ^ ROR32(x, 11) ^ ROR32(x, 25))
- # define SIG0_SHA2(x) (ROR32(x, 7) ^ ROR32(x, 18) ^ ((x) >> 3))
- # define SIG1_SHA2(x) (ROR32(x, 17) ^ ROR32(x, 19) ^ ((x) >> 10))
- # define SHA224 0
- # define SHA256 1
- typedef struct s_sha2
- {
- t_uint8 buff[64];
- t_uint32 state[8];
- t_uint32 count[2];
- } t_sha2;
- typedef struct s_process_sha2
- {
- t_uint32 a;
- t_uint32 b;
- t_uint32 c;
- t_uint32 d;
- t_uint32 e;
- t_uint32 f;
- t_uint32 g;
- t_uint32 h;
- } t_process_sha2;
- void sl_sha2_get_registers(t_uint32 *m, t_process_sha2 *t, \
- size_t i);
- void sl_sha2_process_init_add(t_sha2 *ctx, t_process_sha2 *t, \
- t_bool init);
- void sl_sha2_init(t_sha2 *ctx, t_uint8 sha);
- void sl_sha2_update(t_sha2 *ctx, const t_uint8 *data, size_t len);
- void sl_sha2_final(t_sha2 *ctx);
- void sl_sha2_get_hash(t_sha2 *ctx, t_uint8 *hash);
- #endif
|