8284112: Minor cleanup could be done in javax.crypto

Reviewed-by: wetmore
This commit is contained in:
Mark Powers 2022-04-18 23:48:22 +00:00 committed by Bradford Wetmore
parent 897d6c0dc7
commit 41fc078323
37 changed files with 204 additions and 270 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,14 +25,13 @@
package javax.crypto.spec;
import jdk.internal.access.JavaxCryptoSpecAccess;
import jdk.internal.access.SharedSecrets;
import javax.crypto.SecretKey;
import java.security.MessageDigest;
import java.security.spec.KeySpec;
import java.util.Arrays;
import java.util.Locale;
import javax.crypto.SecretKey;
/**
* This class specifies a secret key in a provider-independent fashion.
@ -61,23 +60,18 @@ public class SecretKeySpec implements KeySpec, SecretKey {
*
* @serial
*/
private byte[] key;
private final byte[] key;
/**
* The name of the algorithm associated with this key.
*
* @serial
*/
private String algorithm;
private final String algorithm;
static {
SharedSecrets.setJavaxCryptoSpecAccess(
new JavaxCryptoSpecAccess() {
@Override
public void clearSecretKeySpec(SecretKeySpec keySpec) {
keySpec.clear();
}
});
SecretKeySpec::clear);
}
/**
@ -210,10 +204,9 @@ public class SecretKeySpec implements KeySpec, SecretKey {
retval += this.key[i] * i;
}
if (this.algorithm.equalsIgnoreCase("TripleDES"))
return (retval ^= "desede".hashCode());
return retval ^ "desede".hashCode();
else
return (retval ^=
this.algorithm.toLowerCase(Locale.ENGLISH).hashCode());
return retval ^ this.algorithm.toLowerCase(Locale.ENGLISH).hashCode();
}
/**