Sha256: 611859aeae4b7f888a5153e6012cc68af1fa567814c3fd6e4eb069431f00edf9
Contents?: true
Size: 1.63 KB
Versions: 2
Compression:
Stored size: 1.63 KB
Contents
#include <ruby.h> #include <stdio.h> #include <openssl/rsa.h> #include <openssl/evp.h> #include <openssl/engine.h> #include <openssl/opensslv.h> static VALUE rb_mOpenSSL; static VALUE rb_mPKey; static VALUE rb_cRSA; static VALUE rb_cRSAError; VALUE openssl_rsa_pss_verify__verify_pss_sha1(VALUE self, VALUE vSig, VALUE vHashData, VALUE vSaltLen) { EVP_PKEY * pkey; EVP_PKEY_CTX * pkey_ctx; int verify_rval; StringValue(vSig); StringValue(vHashData); Data_Get_Struct(self, EVP_PKEY, pkey); pkey_ctx = EVP_PKEY_CTX_new(pkey, ENGINE_get_default_RSA()); EVP_PKEY_verify_init(pkey_ctx); EVP_PKEY_CTX_set_signature_md(pkey_ctx, EVP_sha1()); EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING); EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, NUM2INT(vSaltLen)); verify_rval = EVP_PKEY_verify(pkey_ctx, (unsigned char*)RSTRING_PTR(vSig), RSTRING_LEN(vSig), (unsigned char*)RSTRING_PTR(vHashData), RSTRING_LEN(vHashData)); EVP_PKEY_CTX_free(pkey_ctx); switch (verify_rval) { case 1: return Qtrue; case 0: return Qfalse; default: rb_raise(rb_cRSAError, NULL); } return Qnil; //dummy } void Init_openssl_rsa_pss_verify() { fprintf(stderr, "VERSION: %s\n", SSLeay_version(SSLEAY_VERSION)); rb_mOpenSSL = rb_const_get_at(rb_cObject, rb_intern("OpenSSL")); rb_mPKey = rb_const_get_at(rb_mOpenSSL, rb_intern("PKey")); rb_cRSA = rb_const_get_at(rb_mPKey, rb_intern("RSA")); rb_cRSAError = rb_const_get_at(rb_mPKey, rb_intern("RSAError")); rb_define_method(rb_cRSA, "verify_pss_sha1", openssl_rsa_pss_verify__verify_pss_sha1, 3); }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
openssl_rsa_pss_verify-0.0.2 | ext/openssl_rsa_pss_verify/openssl_rsa_pss_verify_ext.c |
openssl_rsa_pss_verify-0.0.1 | ext/openssl_rsa_pss_verify/openssl_rsa_pss_verify_ext.c |