Signs data
using a private key pkey
. Unlike sign
, data
will not be hashed by digest
automatically.
See verify_raw
for the verification operation.
Added in version 3.0. See also the man page EVP_PKEY_sign(3).
digest
A String
that represents the message digest algorithm name, or nil
if the PKey
type requires no digest algorithm. Although this method will not hash data
with it, this parameter may still be required depending on the signature algorithm.
data
A String
. The data to be signed.
options
A Hash
that contains algorithm specific control operations to OpenSSL. See OpenSSL’s man page EVP_PKEY_CTX_ctrl_str(3) for details.
Example:
data = "Sign me!" hash = OpenSSL::Digest.digest("SHA256", data) pkey = OpenSSL::PKey.generate_key("RSA", rsa_keygen_bits: 2048) signopts = { rsa_padding_mode: "pss" } signature = pkey.sign_raw("SHA256", hash, signopts) # Creates a copy of the RSA key pkey, but without the private components pub_key = pkey.public_key puts pub_key.verify_raw("SHA256", signature, hash, signopts) # => true
Verifies the signature
for the data
using a public key pkey
. Unlike verify
, this method will not hash data
with digest
automatically.
Returns true
if the signature is successfully verified, false
otherwise. The caller must check the return value.
See sign_raw
for the signing operation and an example code.
Added in version 3.0. See also the man page EVP_PKEY_verify(3).
signature
A String
containing the signature to be verified.
Fetch the end line of the value.
Fetch the start byte offset of the value.
Fetch the start byte column of the value.
Fetch the trailing comments of the value.
Configure the trailing comments field for this repository and return self.
This is a hook to allow consumers to disable some errors if they don’t want them to block creating the syntax tree.
This is a hook to allow consumers to disable some warnings if they don’t want them to block creating the syntax tree.
Build a diagnostic from the given prism parse error.
Build a diagnostic from the given prism parse warning.
Build a range from a prism location.
Parses src
and create S-exp tree. This method is mainly for developer use. The filename
argument is mostly ignored. By default, this method does not handle syntax errors in src
, returning nil
in such cases. Use the raise_errors
keyword to raise a SyntaxError
for an error in src
.
require "ripper" require "pp" pp Ripper.sexp_raw("def m(a) nil end") #=> [:program, [:stmts_add, [:stmts_new], [:def, [:@ident, "m", [1, 4]], [:paren, [:params, [[:@ident, "a", [1, 6]]], nil, nil, nil]], [:bodystmt, [:stmts_add, [:stmts_new], [:var_ref, [:@kw, "nil", [1, 9]]]], nil, nil, nil]]]]
Visit a list of elements, like the elements of an array or arguments.
Returns true if there is a comma between the two locations.
This method is called when the parser found syntax error.