зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
8d4d2e4323
Коммит
d9f38cbee8
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
Fri Sep 5 18:00:51 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
Fri Sep 5 15:32:04 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Sep 5 15:32:04 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* misc/ruby-mode.el (ruby-font-lock-maybe-here-docs): should not
|
* misc/ruby-mode.el (ruby-font-lock-maybe-here-docs): should not
|
||||||
|
|
|
@ -88,7 +88,7 @@ module OpenSSL
|
||||||
end # Extension
|
end # Extension
|
||||||
|
|
||||||
class Attribute
|
class Attribute
|
||||||
def Attribute::new(arg)
|
def self.new(arg)
|
||||||
type = arg.class
|
type = arg.class
|
||||||
while type
|
while type
|
||||||
method = "new_from_#{type.name.downcase}".intern
|
method = "new_from_#{type.name.downcase}".intern
|
||||||
|
@ -128,5 +128,12 @@ module OpenSSL
|
||||||
end
|
end
|
||||||
end # Attribute
|
end # Attribute
|
||||||
|
|
||||||
|
class Name
|
||||||
|
def self.parse(str)
|
||||||
|
ary = str.scan(/\s*([^\/,]+)\s*/).collect{|i| i[0].split("=") }
|
||||||
|
self.new(ary)
|
||||||
|
end
|
||||||
|
end # Name
|
||||||
|
|
||||||
end # X509
|
end # X509
|
||||||
end # OpenSSL
|
end # OpenSSL
|
||||||
|
|
|
@ -30,6 +30,8 @@ VALUE mCipher;
|
||||||
VALUE cCipher;
|
VALUE cCipher;
|
||||||
VALUE eCipherError;
|
VALUE eCipherError;
|
||||||
|
|
||||||
|
static VALUE ossl_cipher_alloc(VALUE klass);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PUBLIC
|
* PUBLIC
|
||||||
*/
|
*/
|
||||||
|
@ -43,6 +45,21 @@ GetCipherPtr(VALUE obj)
|
||||||
return EVP_CIPHER_CTX_cipher(ctx);
|
return EVP_CIPHER_CTX_cipher(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VALUE
|
||||||
|
ossl_cipher_new(const EVP_CIPHER *cipher)
|
||||||
|
{
|
||||||
|
VALUE ret;
|
||||||
|
EVP_CIPHER_CTX *ctx;
|
||||||
|
|
||||||
|
ret = ossl_cipher_alloc(cCipher);
|
||||||
|
GetCipher(ret, ctx);
|
||||||
|
EVP_CIPHER_CTX_init(ctx);
|
||||||
|
if (EVP_CipherInit(ctx, cipher, NULL, NULL, -1) != 1)
|
||||||
|
ossl_raise(eCipherError, NULL);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PRIVATE
|
* PRIVATE
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -16,6 +16,7 @@ extern VALUE cCipher;
|
||||||
extern VALUE eCipherError;
|
extern VALUE eCipherError;
|
||||||
|
|
||||||
const EVP_CIPHER *GetCipherPtr(VALUE);
|
const EVP_CIPHER *GetCipherPtr(VALUE);
|
||||||
|
VALUE ossl_cipher_new(const EVP_CIPHER *);
|
||||||
void Init_ossl_cipher(void);
|
void Init_ossl_cipher(void);
|
||||||
|
|
||||||
#endif /* _OSSL_CIPHER_H_ */
|
#endif /* _OSSL_CIPHER_H_ */
|
||||||
|
|
|
@ -28,6 +28,8 @@ VALUE mDigest;
|
||||||
VALUE cDigest;
|
VALUE cDigest;
|
||||||
VALUE eDigestError;
|
VALUE eDigestError;
|
||||||
|
|
||||||
|
static VALUE ossl_digest_alloc(VALUE klass);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Public
|
* Public
|
||||||
*/
|
*/
|
||||||
|
@ -41,6 +43,20 @@ GetDigestPtr(VALUE obj)
|
||||||
return EVP_MD_CTX_md(ctx); /*== ctx->digest*/
|
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
|
* Private
|
||||||
*/
|
*/
|
||||||
|
@ -79,6 +95,7 @@ ossl_digest_initialize(int argc, VALUE *argv, VALUE self)
|
||||||
if (!md) {
|
if (!md) {
|
||||||
ossl_raise(rb_eRuntimeError, "Unsupported digest algorithm (%s).", name);
|
ossl_raise(rb_eRuntimeError, "Unsupported digest algorithm (%s).", name);
|
||||||
}
|
}
|
||||||
|
EVP_MD_CTX_init(ctx);
|
||||||
EVP_DigestInit(ctx, md);
|
EVP_DigestInit(ctx, md);
|
||||||
|
|
||||||
if (!NIL_P(data)) return ossl_digest_update(self, data);
|
if (!NIL_P(data)) return ossl_digest_update(self, data);
|
||||||
|
|
|
@ -16,6 +16,7 @@ extern VALUE cDigest;
|
||||||
extern VALUE eDigestError;
|
extern VALUE eDigestError;
|
||||||
|
|
||||||
const EVP_MD *GetDigestPtr(VALUE);
|
const EVP_MD *GetDigestPtr(VALUE);
|
||||||
|
VALUE ossl_digest_new(const EVP_MD *);
|
||||||
void Init_ossl_digest(void);
|
void Init_ossl_digest(void);
|
||||||
|
|
||||||
#endif /* _OSSL_DIGEST_H_ */
|
#endif /* _OSSL_DIGEST_H_ */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче