Fix openssl req with -addext subjectAltName=dirName
[openssl.git] / test / rsa_x931_test.c
1 /*
2  * Copyright 2022-2023 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 #include "internal/deprecated.h"
11
12 #include <openssl/rsa.h>
13 #include <openssl/bn.h>
14 #include "crypto/rsa.h"
15 #include "testutil.h"
16
17 static OSSL_PROVIDER *prov_null = NULL;
18 static OSSL_LIB_CTX *libctx = NULL;
19
20 static int test_rsa_x931_keygen(void)
21 {
22     int ret = 0;
23     BIGNUM *e = NULL;
24     RSA *rsa = NULL;
25
26     ret = TEST_ptr(rsa = ossl_rsa_new_with_ctx(libctx))
27           && TEST_ptr(e = BN_new())
28           && TEST_int_eq(BN_set_word(e, RSA_F4), 1)
29           && TEST_int_eq(RSA_X931_generate_key_ex(rsa, 1024, e, NULL), 1);
30     BN_free(e);
31     RSA_free(rsa);
32     return ret;
33 }
34
35 int setup_tests(void)
36 {
37     if (!test_get_libctx(&libctx, &prov_null, NULL, NULL, NULL))
38         return 0;
39
40     ADD_TEST(test_rsa_x931_keygen);
41     return 1;
42 }
43
44 void cleanup_tests(void)
45 {
46     OSSL_PROVIDER_unload(prov_null);
47     OSSL_LIB_CTX_free(libctx);
48 }