Does this library support interop with pycrypto? #41
-
Just getting started in this field but for my job i have to provide interop (both ways) with a python library. https://pycryptodome.readthedocs.io/en/latest/src/signature/dsa.html so basically im trying to replicate these two functions in kotlin
and
but i dont see any mention of fips-186-3 in this library/sample code so im not sure if that fips-186-3 is just a standard and i dont need to actually declare that in my kotlin code anywhere? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hey! Yeah, there is no need to provide So to mimic your code here, it will be something like this: val ecdsa = CryptographyProvider.Default.get(ECDSA)
val signature =
ecdsa
.privateKeyDecoder(EC.Curve.P521)
.decodeFrom(EC.PrivateKey.Format.DER, TODO("read bytes from 'privkey.der'"))
.signatureGenerator(SHA256, ECDSA.SignatureFormat.RAW) // python lib used RAW format by default
.generateSignature("I give my permission to order #4355".encodeToByteArray())
val isValid =
ecdsa
.publicKeyDecoder(EC.Curve.P521)
.decodeFrom(EC.PublicKey.Format.DER, TODO("read bytes from 'pubkey.der'"))
.signatureVerifier(SHA256, ECDSA.SignatureFormat.RAW)
.verifySignature("I give my permission to order #4355".encodeToByteArray(), signature)
check(isValid) { "Signature is invalid" } The only thing that is not supported is automatic decoding of curves - you need to provide it explicitly. Hope this helps! |
Beta Was this translation helpful? Give feedback.
Hey! Yeah, there is no need to provide
fips-186-3
, this is the default behaviour now. So everything should work fine.The main difference with this
python
library is that you don't need to hash data yourself, but it will be done under the hood.So to mimic your code here, it will be something like this: