ruby-changes:44211
From: nobu <ko1@a...>
Date: Wed, 28 Sep 2016 23:14:26 +0900 (JST)
Subject: [ruby-changes:44211] nobu:r56284 (trunk): PStoRe: select checksum algorithm
nobu 2016-09-28 23:14:21 +0900 (Wed, 28 Sep 2016) New Revision: 56284 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56284 Log: PStore: select checksum algorithm * lib/pstore.rb (PStore::CHECKSUM_ALGO): find available hashing algorithm for checksum. MD5 is not available in FIPS mode. [Feature #6943] Modified files: trunk/ChangeLog trunk/lib/pstore.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 56283) +++ ChangeLog (revision 56284) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Sep 28 23:14:19 2016 Nobuyoshi Nakada <nobu@r...> + + * lib/pstore.rb (PStore::CHECKSUM_ALGO): find available hashing + algorithm for checksum. MD5 is not available in FIPS mode. + [Feature #6943] + Wed Sep 28 13:00:25 2016 ksss <co000ri@g...> * signal.c (sig_signame): [DOC] Add documentation in the case of Index: lib/pstore.rb =================================================================== --- lib/pstore.rb (revision 56283) +++ lib/pstore.rb (revision 56284) @@ -8,7 +8,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/pstore.rb#L8 # # See PStore for documentation. -require "digest/md5" +require "digest" # # PStore implements a file based persistence mechanism based on a Hash. User @@ -352,7 +352,12 @@ class PStore https://github.com/ruby/ruby/blob/trunk/lib/pstore.rb#L352 private # Constant for relieving Ruby's garbage collector. - CHECKSUM_ALGO = Digest::MD5 + CHECKSUM_ALGO = %w[SHA512 SHA384 SHA256 SHA1 RMD160 MD5].each do |algo| + begin + break Digest(algo) + rescue LoadError + end + end EMPTY_STRING = "" EMPTY_MARSHAL_DATA = Marshal.dump({}) EMPTY_MARSHAL_CHECKSUM = CHECKSUM_ALGO.digest(EMPTY_MARSHAL_DATA) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/