mirror of
https://git.telodendria.io/Telodendria/Cytoplasm.git
synced 2024-10-30 01:00:47 +03:00
[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.
This commit is contained in:
parent
c3646294f5
commit
3843a8d114
2 changed files with 45 additions and 1 deletions
|
@ -28,6 +28,26 @@
|
|||
|
||||
#include <limits.h>
|
||||
|
||||
#if (TLS_IMPL == TLS_OPENSSL) || (TLS_IMPL == TLS_LIBRESSL)
|
||||
|
||||
#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 +284,4 @@ Sha1(char *str)
|
|||
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
||||
#if (TLS_IMPL == TLS_OPENSSL) || (TLS_IMPL == TLS_LIBRESSL)
|
||||
|
||||
#include <openssl/sha.h>
|
||||
#include <Log.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
|
||||
|
|
Loading…
Reference in a new issue