fixed update openssl version

This commit is contained in:
Termina1
2022-10-13 15:42:11 +03:00
parent 01c5f53d4d
commit 198db59818
9 changed files with 20 additions and 49 deletions

View File

@@ -5,13 +5,10 @@ import java.util.Locale
class SignatureConfig {
enum class Algorithm {
SECP256K1,
NIST_P256;
fun getCurveName(): String {
return if (this == SECP256K1) {
"secp256k1"
} else if (this == NIST_P256) {
return if (this == NIST_P256) {
"secp256r1"
} else {
throw IllegalStateException()
@@ -22,7 +19,6 @@ class SignatureConfig {
companion object {
fun algorithmOfString(algo: String): Algorithm {
val algorithm = when (algo.uppercase(Locale.getDefault())) {
"SECP256K1" -> Algorithm.SECP256K1
"NIST_P256", "NIST-P256", "NISTP256", "SECP256R1" -> Algorithm.NIST_P256
else -> throw IllegalArgumentException("Unknown algorithm or not allowed")
}
@@ -33,7 +29,7 @@ class SignatureConfig {
/**
* Signature scheme that we should use
*/
var algorithm: Algorithm = Algorithm.SECP256K1
var algorithm: Algorithm = Algorithm.NIST_P256
/**
* Should we generate signature on this instance if it's not already present
*/

View File

@@ -37,7 +37,7 @@ open class ResponseSignerFactory(
private fun readKey(algorithm: SignatureConfig.Algorithm, pem: PemObject): Pair<ECPrivateKey, Long> {
val keyFactory = KeyFactory.getInstance("EC")
val key = when (algorithm) {
SignatureConfig.Algorithm.SECP256K1, SignatureConfig.Algorithm.NIST_P256 -> {
SignatureConfig.Algorithm.NIST_P256 -> {
val keySpec = PKCS8EncodedKeySpec(pem.content)
keyFactory.generatePrivate(keySpec)
}
@@ -47,10 +47,6 @@ open class ResponseSignerFactory(
throw IllegalStateException("Only EC keys are allowed")
}
if (algorithm == SignatureConfig.Algorithm.SECP256K1 && key.params.toString().indexOf(SignatureConfig.Algorithm.SECP256K1.getCurveName()) < 0) {
throw IllegalStateException("Key is not SECP256K1, generate SECP256K1 or use another algorithm")
}
if (algorithm == SignatureConfig.Algorithm.NIST_P256 && key.params.toString().indexOf(SignatureConfig.Algorithm.NIST_P256.getCurveName()) < 0) {
throw IllegalStateException("Key is not NIST P256, generate NIST P256 or use another algorithm")
}