Fun 0.41.5
The programming language that makes you have fun!
Loading...
Searching...
No Matches
openssl.c File Reference

OpenSSL-based hashing helpers used by crypto-related opcodes. More...

#include <openssl/evp.h>
#include <stdlib.h>
Include dependency graph for openssl.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int EVP_MD_get_size (const EVP_MD *md)
static char * fun_openssl_md5_hex (const unsigned char *data, size_t len)
 Compute MD5 digest and return it as a lowercase hex string.
static char * fun_openssl_sha256_hex (const unsigned char *data, size_t len)
 Compute SHA-256 digest and return it as a lowercase hex string.
static char * fun_openssl_sha512_hex (const unsigned char *data, size_t len)
 Compute SHA-512 digest and return it as a lowercase hex string.
static char * fun_openssl_ripemd160_hex (const unsigned char *data, size_t len)
 Compute RIPEMD-160 digest and return it as a lowercase hex string.

Detailed Description

OpenSSL-based hashing helpers used by crypto-related opcodes.

Provides thin wrappers around OpenSSL EVP routines to compute common digests (MD5, RIPEMD-160, SHA-256, SHA-512). When FUN_WITH_OPENSSL is disabled, these helpers fall back to returning empty strings to keep the VM behavior consistent.

Definition in file openssl.c.

Function Documentation

◆ EVP_MD_get_size()

int EVP_MD_get_size ( const EVP_MD * md)

◆ fun_openssl_md5_hex()

char * fun_openssl_md5_hex ( const unsigned char * data,
size_t len )
static

Compute MD5 digest and return it as a lowercase hex string.

Parameters
dataPointer to input bytes (may be NULL if len==0).
lenNumber of input bytes.
Returns
Newly-allocated NUL-terminated hex string on success; NULL on failure. When FUN_WITH_OPENSSL is disabled, returns an allocated empty string to keep behavior consistent.
Note
The caller owns the returned buffer and must free() it.

Definition at line 44 of file openssl.c.

◆ fun_openssl_ripemd160_hex()

char * fun_openssl_ripemd160_hex ( const unsigned char * data,
size_t len )
static

Compute RIPEMD-160 digest and return it as a lowercase hex string.

On some OpenSSL builds (e.g., 3.x without legacy provider), RIPEMD-160 may be unavailable and EVP_ripemd160() can return NULL.

Parameters
dataPointer to input bytes (may be NULL if len==0).
lenNumber of input bytes.
Returns
Newly-allocated hex string on success; NULL if the digest is unavailable or another error occurs. When FUN_WITH_OPENSSL is disabled, returns an allocated empty string.
Note
The caller must free() the returned buffer.

Definition at line 196 of file openssl.c.

◆ fun_openssl_sha256_hex()

char * fun_openssl_sha256_hex ( const unsigned char * data,
size_t len )
static

Compute SHA-256 digest and return it as a lowercase hex string.

Parameters
dataPointer to input bytes (may be NULL if len==0).
lenNumber of input bytes.
Returns
Newly-allocated hex string on success; NULL on failure. When FUN_WITH_OPENSSL is disabled, returns an allocated empty string.
Note
The caller must free() the returned buffer.

Definition at line 94 of file openssl.c.

◆ fun_openssl_sha512_hex()

char * fun_openssl_sha512_hex ( const unsigned char * data,
size_t len )
static

Compute SHA-512 digest and return it as a lowercase hex string.

Parameters
dataPointer to input bytes (may be NULL if len==0).
lenNumber of input bytes.
Returns
Newly-allocated hex string on success; NULL on failure. When FUN_WITH_OPENSSL is disabled, returns an allocated empty string.
Note
The caller must free() the returned buffer.

Definition at line 143 of file openssl.c.