@@ -87,7 +87,7 @@ public static IRubyObject digest(IRubyObject self, IRubyObject digest, IRubyObje
87
87
final ByteList bytes = data .asString ().getByteList ();
88
88
try {
89
89
Mac mac = getMacInstance (algName );
90
- mac .init ( new SecretKeySpec ( keyBytes , mac .getAlgorithm ()) );
90
+ mac .init ( new SimpleSecretKey ( mac .getAlgorithm (), keyBytes ) );
91
91
mac .update (bytes .getUnsafeBytes (), bytes .getBegin (), bytes .getRealSize ());
92
92
return runtime .newString ( new ByteList (mac .doFinal (), false ) );
93
93
}
@@ -108,7 +108,7 @@ public static IRubyObject hexdigest(IRubyObject self, IRubyObject digest, IRubyO
108
108
final ByteList bytes = data .asString ().getByteList ();
109
109
try {
110
110
final Mac mac = getMacInstance (algName );
111
- mac .init ( new SecretKeySpec ( keyBytes , mac .getAlgorithm ()) );
111
+ mac .init ( new SimpleSecretKey ( mac .getAlgorithm (), keyBytes ) );
112
112
mac .update (bytes .getUnsafeBytes (), bytes .getBegin (), bytes .getRealSize ());
113
113
return runtime .newString ( toHEX ( mac .doFinal () ) );
114
114
}
@@ -135,7 +135,7 @@ public IRubyObject initialize(IRubyObject key, IRubyObject digest) {
135
135
try {
136
136
this .mac = getMacInstance (algName );
137
137
this .key = key .asString ().getBytes ();
138
- mac .init ( new SecretKeySpec ( this . key , mac .getAlgorithm ()) );
138
+ mac .init ( SimpleSecretKey . copy ( mac .getAlgorithm (), this . key ) );
139
139
}
140
140
catch (NoSuchAlgorithmException e ) {
141
141
throw getRuntime ().newNotImplementedError ("Unsupported MAC algorithm (HMAC[-]" + algName + ")" );
@@ -159,7 +159,7 @@ public IRubyObject initialize_copy(final IRubyObject obj) {
159
159
try {
160
160
this .mac = SecurityHelper .getMac (algName );
161
161
this .key = that .key ;
162
- mac .init ( new SecretKeySpec ( key , algName ) );
162
+ mac .init ( SimpleSecretKey . copy ( algName , key ) );
163
163
}
164
164
catch (NoSuchAlgorithmException e ) {
165
165
throw getRuntime ().newNotImplementedError ("Unsupported MAC algorithm (" + algName + ")" );
0 commit comments