void-packages/srcpkgs/taisei/patches/openssl1.patch

96 lines
3.4 KiB
Diff

diff --git a/src/util/sha256.c b/src/util/sha256.c
index 15f4491ee..e01e32279 100644
--- a/src/util/sha256.c
+++ b/src/util/sha256.c
@@ -119,7 +119,7 @@ static void sha256_init(SHA256State *ctx)
ctx->state[7] = 0x5be0cd19;
}
-SHA256State* sha256_new(void) {
+SHA256State *sha256_new(void) {
SHA256State *ctx = calloc(1, sizeof(*ctx));
sha256_init(ctx);
return ctx;
@@ -129,8 +129,7 @@ void sha256_free(SHA256State *ctx) {
free(ctx);
}
-void sha256_update(SHA256State *ctx, const sha256_byte_t data[], size_t len)
-{
+void sha256_update(SHA256State *ctx, const sha256_byte_t data[], size_t len) {
sha256_word_t i;
for (i = 0; i < len; ++i) {
@@ -144,8 +143,7 @@ void sha256_update(SHA256State *ctx, const sha256_byte_t data[], size_t len)
}
}
-void sha256_final(SHA256State *ctx, sha256_byte_t hash[], size_t hashlen)
-{
+void sha256_final(SHA256State *ctx, sha256_byte_t hash[], size_t hashlen) {
assert(hashlen >= SHA256_BLOCK_SIZE);
sha256_word_t i;
@@ -201,8 +199,8 @@ void sha256_digest(const uint8_t *data, size_t len, uint8_t hash[SHA256_BLOCK_SI
sha256_final(&ctx, hash, hashlen);
}
-void sha256_hexdigest(const uint8_t *data, size_t len, char hash[SHA256_BLOCK_SIZE*2+1], size_t hashlen) {
- assert(hashlen >= SHA256_BLOCK_SIZE * 2 + 1);
+void sha256_hexdigest(const uint8_t *data, size_t len, char hash[SHA256_HEXDIGEST_SIZE], size_t hashlen) {
+ assert(hashlen >= SHA256_HEXDIGEST_SIZE);
uint8_t digest[SHA256_BLOCK_SIZE];
sha256_digest(data, len, digest, sizeof(digest));
diff --git a/src/util/sha256.h b/src/util/sha256.h
index 191246c91..f501e2d98 100644
--- a/src/util/sha256.h
+++ b/src/util/sha256.h
@@ -11,16 +11,19 @@
#include "taisei.h"
-#define SHA256_BLOCK_SIZE 32
+enum {
+ SHA256_BLOCK_SIZE = 32,
+ SHA256_HEXDIGEST_SIZE = SHA256_BLOCK_SIZE * 2 + 1,
+};
typedef struct SHA256State SHA256State;
-SHA256State* sha256_new(void) attr_returns_allocated;
+SHA256State *sha256_new(void) attr_returns_allocated;
void sha256_update(SHA256State *state, const uint8_t *data, size_t len) attr_nonnull(1, 2);
void sha256_final(SHA256State *state, uint8_t hash[SHA256_BLOCK_SIZE], size_t hashlen) attr_nonnull(1, 2);
void sha256_free(SHA256State *state);
void sha256_digest(const uint8_t *data, size_t len, uint8_t hash[SHA256_BLOCK_SIZE], size_t hashlen);
-void sha256_hexdigest(const uint8_t *data, size_t len, char hash[SHA256_BLOCK_SIZE*2+1], size_t hashlen);
+void sha256_hexdigest(const uint8_t *data, size_t len, char hash[SHA256_HEXDIGEST_SIZE], size_t hashlen);
#endif // IGUARD_util_sha256_h
diff --git a/src/util/sha256_openssl.c b/src/util/sha256_openssl.c
index b6f8e9039..0dc06e740 100644
--- a/src/util/sha256_openssl.c
+++ b/src/util/sha256_openssl.c
@@ -17,7 +17,7 @@ struct SHA256State {
SHA256_CTX context;
};
-SHA256State* sha256_new(void) {
+SHA256State *sha256_new(void) {
SHA256State *st = calloc(1, sizeof(*st));
SHA256_Init(&st->context);
return st;
@@ -45,8 +45,8 @@ void sha256_digest(const uint8_t *data, size_t len, uint8_t hash[SHA256_BLOCK_SI
SHA256_Final(hash, &ctx);
}
-void sha256_hexdigest(const uint8_t *data, size_t len, char hash[SHA256_BLOCK_SIZE*2+1], size_t hashlen) {
- assert(hashlen >= SHA256_BLOCK_SIZE * 2 + 1);
+void sha256_hexdigest(const uint8_t *data, size_t len, char hash[SHA256_HEXDIGEST_SIZE], size_t hashlen) {
+ assert(hashlen >= SHA256_HEXDIGEST_SIZE);
uint8_t digest[SHA256_BLOCK_SIZE];
sha256_digest(data, len, digest, sizeof(digest));