Compare commits

..

6 commits

Author SHA1 Message Date
f5ce4f5238 Merge pull request 'Start optionally using the SHA implementation from the existing crypto API' (#44) from lda/Cytoplasm:opt-ssl-for-sha into master
Some checks failed
Compile Cytoplasm / Compile Cytoplasm (x86, alpine-v3.19) (push) Has been cancelled
Compile Cytoplasm / Compile Cytoplasm (x86, debian-v12.4) (push) Has been cancelled
Compile Cytoplasm / Compile Cytoplasm (x86, freebsd-v14.0) (push) Has been cancelled
Compile Cytoplasm / Compile Cytoplasm (x86, netbsd-v9.3) (push) Has been cancelled
Compile Cytoplasm / Compile Cytoplasm (x86_64, alpine-v3.19) (push) Has been cancelled
Compile Cytoplasm / Compile Cytoplasm (x86_64, debian-v12.4) (push) Has been cancelled
Compile Cytoplasm / Compile Cytoplasm (x86_64, freebsd-v14.0) (push) Has been cancelled
Compile Cytoplasm / Compile Cytoplasm (x86_64, netbsd-v9.3) (push) Has been cancelled
Compile Cytoplasm / Compile Cytoplasm (x86_64, openbsd-v7.4) (push) Has been cancelled
Reviewed-on: #44
2024-08-24 13:06:04 -04:00
LDA
7752ea7b86 [MOD] Drop LibreSSL "support" in SHA for now
We'll test later...
2024-08-23 22:45:24 +02:00
LDA
d00dcc9b50 Merge branch 'master' of https://git.telodendria.io/Telodendria/Cytoplasm into opt-ssl-for-sha 2024-08-23 22:44:33 +02:00
lda
c7204f316c Merge branch 'master' into opt-ssl-for-sha 2024-08-16 12:33:11 -04:00
LDA
e8543bdb2a [FIX/WIP] Don't include Log. 2024-08-16 18:26:19 +02:00
LDA
3843a8d114 [MOD/WIP] Get SHA to use Open/LibreSSL if present
I still haven't tested on LibreSSL (Debian doesn't seem to actually like
it all that much), but manuals seems to state that they're the same in
that regard. If anyone is up to verify, let me know so that I'm aware
it's safe to merge it.
2024-08-16 18:22:53 +02:00
2 changed files with 46 additions and 1 deletions

View file

@ -28,6 +28,27 @@
#include <limits.h>
/* TODO: Verify LibreSSL support later */
#if TLS_IMPL == TLS_OPENSSL
#include <openssl/sha.h>
unsigned char *
Sha1(char *str)
{
unsigned char *digest;
if (!str)
{
return NULL;
}
digest = Malloc(20 + 1);
SHA1((unsigned char *) str, strlen(str), digest);
digest[20] = '\0';
return digest;
}
#else
#define LOAD32H(x, y) \
{ \
x = ((uint32_t)((y)[0] & 255) << 24) | \
@ -264,3 +285,4 @@ Sha1(char *str)
return out;
}
#endif

View file

@ -21,14 +21,36 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <Sha.h>
#include <Memory.h>
#include <Sha.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
/* TODO: Verify LibreSSL support later */
#if TLS_IMPL == TLS_OPENSSL
#include <openssl/sha.h>
unsigned char *
Sha256(char *str)
{
unsigned char *digest;
if (!str)
{
return NULL;
}
digest = Malloc(32 + 1);
SHA256((unsigned char *) str, strlen(str), digest);
digest[32] = '\0';
return digest;
}
#else
#define GET_UINT32(x) \
(((uint32_t)(x)[0] << 24) | \
((uint32_t)(x)[1] << 16) | \
@ -230,3 +252,4 @@ Sha256(char *str)
return out;
}
#endif