instance method
OpenSSL::Engine#cipher
(::String cipher) -> ::OpenSSL::Cipher
engine.cipher(name) → OpenSSL::Cipher
ext/openssl/ossl_engine.c
View on GitHub ↗
static VALUE
ossl_engine_get_cipher(VALUE self, VALUE name)
{
ENGINE *e;
const EVP_CIPHER *ciph, *tmp;
int nid;
tmp = EVP_get_cipherbyname(StringValueCStr(name));
if(!tmp) ossl_raise(eEngineError, "no such cipher `%"PRIsVALUE"'", name);
nid = EVP_CIPHER_nid(tmp);
GetEngine(self, e);
ciph = ENGINE_get_cipher(e, nid);
if(!ciph) ossl_raise(eEngineError, NULL);
return ossl_cipher_new(ciph);
}
Returns a new instance of OpenSSL::Cipher by name, if it is available in this engine.
An EngineError will be raised if the cipher is unavailable.
e = OpenSSL::Engine.by_id("openssl")
=> #<OpenSSL::Engine id="openssl" name="Software engine support">
e.cipher("RC4")
=> #<OpenSSL::Cipher:0x007fc5cacc3048>