dipto181

rsa-engine.c

Apr 12th, 2021
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #include <openssl/engine.h>
  5. #include <openssl/sha.h>
  6. #include <openssl/aes.h>
  7. #include <openssl/rsa.h>
  8. #include <openssl/evp.h>
  9. #include <openssl/async.h>
  10. #include <openssl/bn.h>
  11. #include <openssl/crypto.h>
  12. #include <openssl/ssl.h>
  13. #include <openssl/modes.h>
  14.  
  15. /* Engine Id and Name */
  16. static const char *engine_dasync_id = "dasync";
  17. static const char *engine_dasync_name = "Dummy Async engine support";
  18.  
  19. static int dasync_pub_enc(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding) {
  20. printf("dasync_pub_enc\n");
  21. return 0;
  22. }
  23.  
  24. static int dasync_pub_dec(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding) {
  25. printf("dasync_pub_dec\n");
  26. return 0;
  27. }
  28.  
  29. static int dasync_rsa_priv_enc(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding){
  30. printf("dasync_rsa_priv_enc\n");
  31. return 0;
  32. }
  33.  
  34. static int dasync_rsa_priv_dec(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding){
  35. printf("dasync_rsa_priv_dec\n");
  36. return 0;
  37. }
  38.  
  39. static RSA_METHOD *dasync_rsa_method = NULL;
  40. static int bind_dasync(ENGINE *e){
  41. /* Setup RSA_METHOD */
  42. if ((dasync_rsa_method = RSA_meth_new("Dummy Async RSA method", 0)) == NULL
  43. || RSA_meth_set_pub_enc(dasync_rsa_method, dasync_pub_enc) == 0
  44. || RSA_meth_set_pub_dec(dasync_rsa_method, dasync_pub_dec) == 0
  45. || RSA_meth_set_priv_enc(dasync_rsa_method, dasync_rsa_priv_enc) == 0
  46. || RSA_meth_set_priv_dec(dasync_rsa_method, dasync_rsa_priv_dec) == 0
  47. ) {
  48. return 0;
  49. }
  50.  
  51. if (!ENGINE_set_id(e, engine_dasync_id)
  52. || !ENGINE_set_name(e, engine_dasync_name)
  53. || !ENGINE_set_RSA(e, dasync_rsa_method)
  54. ) {
  55. return 0;
  56. }
  57. return 1;
  58. }
  59.  
  60. static int bind_helper(ENGINE *e, const char *id){
  61. if (!bind_dasync(e)){
  62. printf("2_Error: Inside Bind helper\n");
  63. return 0;
  64. }
  65. return 1;
  66. }
  67.  
  68. IMPLEMENT_DYNAMIC_BIND_FN(bind_helper)
  69. IMPLEMENT_DYNAMIC_CHECK_FN()
Advertisement
Add Comment
Please, Sign In to add comment