mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 21:14:23 +02:00

Update the references to the file "LICENCE" with "COPYING". The file LICENCE doesn't exist in ruby/ruby nor ruby/openssl. This has been always the case since OpenSSL for Ruby 2 was merged to the ruby tree as a standard library in 2003. In OpenSSL for Ruby 2's CVS repository[1], the LICENCE file contained an old version of the Ruby License, identical to the COPYING file that was in Ruby's tree at that time (r4128[2]). [1] http://cvs.savannah.gnu.org/viewvc/rubypki/ossl2/LICENCE?revision=1.1.1.1&view=markup [2]231247c010/COPYING
5bccf07d04
37 lines
1 KiB
Ruby
37 lines
1 KiB
Ruby
# frozen_string_literal: true
|
|
=begin
|
|
= Info
|
|
'OpenSSL for Ruby 2' project
|
|
Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
|
|
All rights reserved.
|
|
|
|
= Licence
|
|
This program is licensed under the same licence as Ruby.
|
|
(See the file 'COPYING'.)
|
|
=end
|
|
|
|
require 'openssl.so'
|
|
|
|
require_relative 'openssl/bn'
|
|
require_relative 'openssl/pkey'
|
|
require_relative 'openssl/cipher'
|
|
require_relative 'openssl/digest'
|
|
require_relative 'openssl/hmac'
|
|
require_relative 'openssl/x509'
|
|
require_relative 'openssl/ssl'
|
|
require_relative 'openssl/pkcs5'
|
|
require_relative 'openssl/version'
|
|
|
|
module OpenSSL
|
|
# call-seq:
|
|
# OpenSSL.secure_compare(string, string) -> boolean
|
|
#
|
|
# Constant time memory comparison. Inputs are hashed using SHA-256 to mask
|
|
# the length of the secret. Returns +true+ if the strings are identical,
|
|
# +false+ otherwise.
|
|
def self.secure_compare(a, b)
|
|
hashed_a = OpenSSL::Digest.digest('SHA256', a)
|
|
hashed_b = OpenSSL::Digest.digest('SHA256', b)
|
|
OpenSSL.fixed_length_secure_compare(hashed_a, hashed_b) && a == b
|
|
end
|
|
end
|