Debian Codegraph @

ext/openssl/lib/openssl.rb

raw symbols SCIP
1 # frozen_string_literal: true
2 =begin
3 = Info
4 'OpenSSL for Ruby 2' project
5 Copyright (C) 2002 Michal Rokos <[email protected]>
6 All rights reserved.
7
8 = Licence
9 This program is licensed under the same licence as Ruby.
10 (See the file 'LICENCE'.)
11 =end
12
13 require 'openssl.so'
14
15 require_relative 'openssl/bn'
16 require_relative 'openssl/pkey'
17 require_relative 'openssl/cipher'
18 require_relative 'openssl/digest'
19 require_relative 'openssl/hmac'
20 require_relative 'openssl/x509'
21 require_relative 'openssl/ssl'
22 require_relative 'openssl/pkcs5'
23 require_relative 'openssl/version'
24
25 module OpenSSL
26 # call-seq:
27 # OpenSSL.secure_compare(string, string) -> boolean
28 #
29 # Constant time memory comparison. Inputs are hashed using SHA-256 to mask
30 # the length of the secret. Returns +true+ if the strings are identical,
31 # +false+ otherwise.
32 def self.secure_compare(a, b)
33 hashed_a = OpenSSL::Digest.digest('SHA256', a)
34 hashed_b = OpenSSL::Digest.digest('SHA256', b)
35 OpenSSL.fixed_length_secure_compare(hashed_a, hashed_b) && a == b
36 end
37 end