rsa_x931_test.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #include "internal/deprecated.h"
  10. #include <openssl/rsa.h>
  11. #include <openssl/bn.h>
  12. #include "crypto/rsa.h"
  13. #include "testutil.h"
  14. static OSSL_PROVIDER *prov_null = NULL;
  15. static OSSL_LIB_CTX *libctx = NULL;
  16. static int test_rsa_x931_keygen(void)
  17. {
  18. int ret = 0;
  19. BIGNUM *e = NULL;
  20. RSA *rsa = NULL;
  21. ret = TEST_ptr(rsa = ossl_rsa_new_with_ctx(libctx))
  22. && TEST_ptr(e = BN_new())
  23. && TEST_int_eq(BN_set_word(e, RSA_F4), 1)
  24. && TEST_int_eq(RSA_X931_generate_key_ex(rsa, 1024, e, NULL), 1);
  25. BN_free(e);
  26. RSA_free(rsa);
  27. return ret;
  28. }
  29. int setup_tests(void)
  30. {
  31. if (!test_get_libctx(&libctx, &prov_null, NULL, NULL, NULL))
  32. return 0;
  33. ADD_TEST(test_rsa_x931_keygen);
  34. return 1;
  35. }
  36. void cleanup_tests(void)
  37. {
  38. OSSL_PROVIDER_unload(prov_null);
  39. OSSL_LIB_CTX_free(libctx);
  40. }