Skip to content

Commit a23f354

Browse files
committed
Refine
1 parent 10bff1d commit a23f354

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/main/java/com/hardssh/provider/FIDOSignatureParameters.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.security.spec.AlgorithmParameterSpec;
55
import java.util.Objects;
66

7+
@SuppressWarnings("ArrayRecordComponent")
78
public record FIDOSignatureParameters(byte[] appdata, int counter, byte flags) implements AlgorithmParameterSpec {
89

910
public FIDOSignatureParameters {

src/main/java/com/hardssh/provider/SSHKeyStoreSpi.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public KeyStore.Entry engineGetEntry(String alias, KeyStore.ProtectionParameter
9898
return resolveAlias(alias);
9999
}
100100

101+
@SuppressWarnings("JavaUtilDate")
101102
@Override
102103
public Date engineGetCreationDate(String alias) {
103104
var e = resolveAlias(alias);
@@ -219,7 +220,7 @@ public void engineStore(OutputStream stream, char[] password) throws IOException
219220
throw new UnsupportedOperationException("SSH agent keystore is read-only, in-memory");
220221
}
221222

222-
private Collection<SSHIdentityWithComment<? extends SSHIdentity>> fetchIdentities() {
223+
private Set<SSHIdentityWithComment<? extends SSHIdentity>> fetchIdentities() {
223224

224225
try {
225226
var reply = runCommand(socket, new RequestIdentities());
@@ -232,10 +233,10 @@ private Collection<SSHIdentityWithComment<? extends SSHIdentity>> fetchIdentitie
232233
} else {
233234
log.warning("Could not list identities: " + AgentMessage.name(type));
234235
}
235-
return found;
236+
return Collections.unmodifiableSet(found);
236237
} catch (IOException e) {
237238
log.warning("Could not list identities: " + e.getMessage());
238-
return Collections.emptyList();
239+
return Collections.emptySet();
239240
}
240241
}
241242

src/main/java/com/hardssh/provider/SSHSIGSignatureSpi.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.nio.ByteBuffer;
1010
import java.security.*;
1111
import java.security.spec.AlgorithmParameterSpec;
12+
import java.util.Locale;
1213
import java.util.Map;
1314
import java.util.logging.Logger;
1415

@@ -117,7 +118,7 @@ protected byte[] engineSign() throws SignatureException {
117118
digest.reset();
118119

119120
// The hash name in ssh lingo (tolower and remove -)
120-
var hash_algo = digest.getAlgorithm().toLowerCase().replace("-", "");
121+
var hash_algo = digest.getAlgorithm().toLowerCase(Locale.ENGLISH).replace("-", "");
121122

122123
try {
123124
// The key type is the signature type as well, unless it is RSA, when it depends on used hash.
@@ -161,7 +162,7 @@ protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
161162
var hash = digest.digest();
162163
digest.reset();
163164

164-
var hash_algo = digest.getAlgorithm().toLowerCase().replace("-", "");
165+
var hash_algo = digest.getAlgorithm().toLowerCase(Locale.ENGLISH).replace("-", "");
165166

166167
try {
167168
var sshsig = SSHSIG.PARSER.fromBytes(sigBytes);
@@ -176,7 +177,7 @@ protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
176177
}
177178
} else {
178179
// verify that the hash in sshsig matches the hash we use
179-
var paramhash = params.hash().toLowerCase().replace("-", "");
180+
var paramhash = params.hash().toLowerCase(Locale.ENGLISH).replace("-", "");
180181
if (!paramhash.equals(sshsig.hash_algorithm())) {
181182
throw new SignatureException("SSHSIG hash mismatch: " + sshsig.hash_algorithm() + " != " + paramhash);
182183
}

0 commit comments

Comments
 (0)