| 1 |
#include <openssl/engine.h> |
| 2 |
#include <openssl/crypto.h> |
| 3 |
#include <openssl/opensslv.h> |
| 4 |
int main() |
| 5 |
{ |
| 6 |
ENGINE* eg; |
| 7 |
const EVP_MD* EVP_GOST_34_11; |
| 8 |
|
| 9 |
/* Initialise OpenSSL */ |
| 10 |
OpenSSL_add_all_algorithms(); |
| 11 |
|
| 12 |
/* Load engines */ |
| 13 |
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) |
| 14 |
ENGINE_load_builtin_engines(); |
| 15 |
#else |
| 16 |
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_ALL_BUILTIN | OPENSSL_INIT_LOAD_CONFIG, NULL); |
| 17 |
#endif |
| 18 |
|
| 19 |
/* Initialise the GOST engine */ |
| 20 |
eg = ENGINE_by_id("gost"); |
| 21 |
if (eg == NULL) |
| 22 |
return 1; |
| 23 |
if (ENGINE_init(eg) <= 0) |
| 24 |
return 1; |
| 25 |
|
| 26 |
/* better than digest_gost */ |
| 27 |
EVP_GOST_34_11 = ENGINE_get_digest(eg, NID_id_GostR3411_94); |
| 28 |
if (EVP_GOST_34_11 == NULL) |
| 29 |
return 1; |
| 30 |
|
| 31 |
/* from the openssl.cnf */ |
| 32 |
if (ENGINE_register_pkey_asn1_meths(eg) <= 0) |
| 33 |
return 1; |
| 34 |
if (ENGINE_ctrl_cmd_string(eg, |
| 35 |
"CRYPT_PARAMS", |
| 36 |
"id-Gost28147-89-CryptoPro-A-ParamSet", |
| 37 |
0) <= 0) |
| 38 |
return 1; |
| 39 |
|
| 40 |
return 0; |
| 41 |
} |