summaryrefslogtreecommitdiff
path: root/ext/openssl/ossl_digest.c
diff options
context:
space:
mode:
authorgotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-05 09:08:40 +0000
committergotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-05 09:08:40 +0000
commitd9f38cbee88fdbb06d8577496062918da39fdeab (patch)
tree32333543a60cb2accc56c0b4377114324e1166b6 /ext/openssl/ossl_digest.c
parent8d4d2e43233afcb075b4663828568bd5a5f16712 (diff)
* ext/openssl/lib/openssl/x509.rb: new method X509::Name::parse.
* ext/openssl/ossl_digest.c: add ossl_digest_new(). * ext/openssl/ossl_digest.h: ditto. * ext/openssl/ossl_cipher.c: add ossl_cipher_new(). * ext/openssl/ossl_cipher.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl_digest.c')
-rw-r--r--ext/openssl/ossl_digest.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/ext/openssl/ossl_digest.c b/ext/openssl/ossl_digest.c
index e04b145..8511ecc 100644
--- a/ext/openssl/ossl_digest.c
+++ b/ext/openssl/ossl_digest.c
@@ -28,6 +28,8 @@ VALUE mDigest;
VALUE cDigest;
VALUE eDigestError;
+static VALUE ossl_digest_alloc(VALUE klass);
+
/*
* Public
*/
@@ -41,6 +43,20 @@ GetDigestPtr(VALUE obj)
return EVP_MD_CTX_md(ctx); /*== ctx->digest*/
}
+VALUE
+ossl_digest_new(const EVP_MD *md)
+{
+ VALUE ret;
+ EVP_MD_CTX *ctx;
+
+ ret = ossl_digest_alloc(cDigest);
+ GetDigest(ret, ctx);
+ EVP_MD_CTX_init(ctx);
+ EVP_DigestInit(ctx, md);
+
+ return ret;
+}
+
/*
* Private
*/
@@ -79,6 +95,7 @@ ossl_digest_initialize(int argc, VALUE *argv, VALUE self)
if (!md) {
ossl_raise(rb_eRuntimeError, "Unsupported digest algorithm (%s).", name);
}
+ EVP_MD_CTX_init(ctx);
EVP_DigestInit(ctx, md);
if (!NIL_P(data)) return ossl_digest_update(self, data);