mirror of https://github.com/shred/acme4j
Accepting hmac key of all sizes (#144)
parent
5ef39534ec
commit
f61ef3ede7
|
@ -245,19 +245,15 @@ public final class JoseUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
var size = macKey.getEncoded().length * 8;
|
var size = macKey.getEncoded().length * 8;
|
||||||
switch (size) {
|
if(size < 256) {
|
||||||
case 256:
|
throw new IllegalArgumentException("Bad key size: " + size);
|
||||||
return AlgorithmIdentifiers.HMAC_SHA256;
|
}
|
||||||
|
if (size >= 512) {
|
||||||
case 384:
|
return AlgorithmIdentifiers.HMAC_SHA512;
|
||||||
return AlgorithmIdentifiers.HMAC_SHA384;
|
} else if (size >= 384) {
|
||||||
|
return AlgorithmIdentifiers.HMAC_SHA384;
|
||||||
case 512:
|
} else {
|
||||||
return AlgorithmIdentifiers.HMAC_SHA512;
|
return AlgorithmIdentifiers.HMAC_SHA256;
|
||||||
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Bad key size: " + size);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue