feat(libft_ssl): declare algo interfaces and scaffold per-function stubs
This commit is contained in:
parent
35c32a9c32
commit
d08103532b
11 changed files with 96 additions and 12 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef MD5_H
|
#ifndef MD5_H
|
||||||
#define MD5_H
|
#define MD5_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
struct md5_ctx
|
struct md5_ctx
|
||||||
|
|
@ -10,4 +11,15 @@ struct md5_ctx
|
||||||
uint8_t buf[64];
|
uint8_t buf[64];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void md5_init(void *ctx);
|
||||||
|
void md5_update(void *ctx, const uint8_t *data, size_t len);
|
||||||
|
void md5_final(void *ctx, uint8_t *out);
|
||||||
|
|
||||||
|
/* RFC 1321 — per-step sine-derived constants (64 values) */
|
||||||
|
extern const uint32_t g_md5_T[64];
|
||||||
|
|
||||||
|
/* RFC 1321 — per-step left-rotation amounts (4 rounds x 4 values, each
|
||||||
|
* repeated 4 times) */
|
||||||
|
extern const uint32_t g_md5_s[64];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef SHA256_H
|
#ifndef SHA256_H
|
||||||
#define SHA256_H
|
#define SHA256_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
struct sha256_ctx
|
struct sha256_ctx
|
||||||
|
|
@ -10,4 +11,8 @@ struct sha256_ctx
|
||||||
uint8_t buf[64];
|
uint8_t buf[64];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void sha256_init(void *ctx);
|
||||||
|
void sha256_update(void *ctx, const uint8_t *data, size_t len);
|
||||||
|
void sha256_final(void *ctx, uint8_t *out);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,13 @@
|
||||||
lib_LTLIBRARIES = libft_ssl.la
|
lib_LTLIBRARIES = libft_ssl.la
|
||||||
|
|
||||||
libft_ssl_la_SOURCES = libft_ssl.c
|
libft_ssl_la_SOURCES = libft_ssl.c \
|
||||||
|
md5/md5.c \
|
||||||
|
md5/md5_init.c \
|
||||||
|
md5/md5_update.c \
|
||||||
|
md5/md5_final.c \
|
||||||
|
sha256/sha256_init.c \
|
||||||
|
sha256/sha256_update.c \
|
||||||
|
sha256/sha256_final.c
|
||||||
|
|
||||||
AM_CFLAGS = -std=c99 $(STRICT_CFLAGS)
|
AM_CFLAGS = -std=c99 $(STRICT_CFLAGS)
|
||||||
libft_ssl_la_CPPFLAGS = -I$(top_srcdir)/include
|
libft_ssl_la_CPPFLAGS = -I$(top_srcdir)/include
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,5 @@
|
||||||
#include "compiler.h"
|
|
||||||
#include "libft_ssl.h"
|
#include "libft_ssl.h"
|
||||||
|
|
||||||
#define DIGEST_ALGO(lower, ds, bs) \
|
|
||||||
static void lower##_init(__unused void *ctx) {} \
|
|
||||||
static void lower##_update(__unused void *ctx, \
|
|
||||||
__unused const uint8_t *data, \
|
|
||||||
__unused size_t len) {} \
|
|
||||||
static void lower##_final(__unused void *ctx, \
|
|
||||||
__unused uint8_t *out) {}
|
|
||||||
#include "digest_algos.h"
|
|
||||||
#undef DIGEST_ALGO
|
|
||||||
|
|
||||||
#define DIGEST_ALGO(lower, ds, bs) \
|
#define DIGEST_ALGO(lower, ds, bs) \
|
||||||
const struct digest_algo g_##lower = { \
|
const struct digest_algo g_##lower = { \
|
||||||
.name = #lower, \
|
.name = #lower, \
|
||||||
|
|
|
||||||
33
src/md5/md5.c
Normal file
33
src/md5/md5.c
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
#include "md5.h"
|
||||||
|
|
||||||
|
/* Each round uses 4 rotation values, repeated 4 times across 16 steps */
|
||||||
|
#define S_ROUND(a, b, c, d) (a), (b), (c), (d), (a), (b), (c), (d), \
|
||||||
|
(a), (b), (c), (d), (a), (b), (c), (d)
|
||||||
|
|
||||||
|
const uint32_t g_md5_s[64] = {
|
||||||
|
S_ROUND( 7, 12, 17, 22),
|
||||||
|
S_ROUND( 5, 9, 14, 20),
|
||||||
|
S_ROUND( 4, 11, 16, 23),
|
||||||
|
S_ROUND( 6, 10, 15, 21),
|
||||||
|
};
|
||||||
|
|
||||||
|
#undef S_ROUND
|
||||||
|
|
||||||
|
const uint32_t g_md5_T[64] = {
|
||||||
|
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
|
||||||
|
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
|
||||||
|
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
|
||||||
|
0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
|
||||||
|
0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
|
||||||
|
0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
|
||||||
|
0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
|
||||||
|
0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
|
||||||
|
0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
|
||||||
|
0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
|
||||||
|
0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
|
||||||
|
0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
|
||||||
|
0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
|
||||||
|
0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
|
||||||
|
0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
|
||||||
|
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391,
|
||||||
|
};
|
||||||
6
src/md5/md5_final.c
Normal file
6
src/md5/md5_final.c
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "compiler.h"
|
||||||
|
#include "md5.h"
|
||||||
|
|
||||||
|
void md5_final(__unused void *ctx, __unused uint8_t *out)
|
||||||
|
{
|
||||||
|
}
|
||||||
6
src/md5/md5_init.c
Normal file
6
src/md5/md5_init.c
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "compiler.h"
|
||||||
|
#include "md5.h"
|
||||||
|
|
||||||
|
void md5_init(__unused void *ctx)
|
||||||
|
{
|
||||||
|
}
|
||||||
7
src/md5/md5_update.c
Normal file
7
src/md5/md5_update.c
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include "compiler.h"
|
||||||
|
#include "md5.h"
|
||||||
|
|
||||||
|
void md5_update(__unused void *ctx, __unused const uint8_t *data,
|
||||||
|
__unused size_t len)
|
||||||
|
{
|
||||||
|
}
|
||||||
6
src/sha256/sha256_final.c
Normal file
6
src/sha256/sha256_final.c
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "compiler.h"
|
||||||
|
#include "sha256.h"
|
||||||
|
|
||||||
|
void sha256_final(__unused void *ctx, __unused uint8_t *out)
|
||||||
|
{
|
||||||
|
}
|
||||||
6
src/sha256/sha256_init.c
Normal file
6
src/sha256/sha256_init.c
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "compiler.h"
|
||||||
|
#include "sha256.h"
|
||||||
|
|
||||||
|
void sha256_init(__unused void *ctx)
|
||||||
|
{
|
||||||
|
}
|
||||||
7
src/sha256/sha256_update.c
Normal file
7
src/sha256/sha256_update.c
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include "compiler.h"
|
||||||
|
#include "sha256.h"
|
||||||
|
|
||||||
|
void sha256_update(__unused void *ctx, __unused const uint8_t *data,
|
||||||
|
__unused size_t len)
|
||||||
|
{
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue