ecdsa

Loading raw 64-byte long ECDSA public key in Java

为君一笑 提交于 2019-11-27 14:26:32
I have a raw (r,s) format ECDSA NIST P-256 public key. It seems that there is no simple way to load it into an object that implements java.security.interfaces.ECPublicKey. What is the cleanest way to load a 64 byte public key so that it can be used to check signatures? This answer is going to be tough if we do this using ECPublicKeySpec . So lets cheat a bit: private static byte[] P256_HEAD = Base64.getDecoder().decode("MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE"); public static ECPublicKey convertP256Key(byte[] w) throws InvalidKeySpecException { byte[] encodedKey = new byte[P256_HEAD.length + w

ECDSA sign with BouncyCastle and verify with Crypto++

▼魔方 西西 提交于 2019-11-27 08:15:09
问题 Here is the Java code: public static String sign(String data) throws Exception { KeyPair keyPair = loadKeyPair(System.getProperty("user.dir"), "ECDSA"); Signature signature = Signature.getInstance("SHA256withECDSA", "BC"); signature.initSign(keyPair.getPrivate(), new SecureRandom()); byte[] message = data.getBytes(); signature.update(message); byte[] sigBytes = signature.sign(); String signatureStr = new BigInteger(1, sigBytes).toString(16); return signatureStr; } Then the C++ Code to verify

ECDSA signatures between Node.js and WebCrypto appear to be incompatible?

社会主义新天地 提交于 2019-11-27 06:56:20
问题 I'm using the following example for signing + verifying in Node.js: https://github.com/nodejs/node-v0.x-archive/issues/6904. The verification succeeds in Node.js but fails in WebCrypto. Similarly, a message signed using WebCrypto fails to verify in Node.js. Here's the code I used to verify a signature produced from the Node.js script using WebCrypto - https://jsfiddle.net/aj49e8sj/. Tested in both Chrome 54.0.2840.27 and Firefox 48.0.2 // From https://github.com/nodejs/node-v0.x-archive

ECDSA sign with OpenSSL, verify with Crypto++

て烟熏妆下的殇ゞ 提交于 2019-11-26 21:59:02
问题 I create an ECDSA keypair (secp128r1) in my application with Wei Dai's Crypto++. Signing and verifying works as expected. I do not add the message itself to the signature to minimize the signature length (which is exactly 32 Bytes). However, when I create the signature with openssl: $ cat test.txt | openssl dgst -ecdsa-with-SHA1 -sign sample.key -keyform DER > act.bin OpenSSL obviously puts the message itself to the signature resulting in a larger signature (e.g. 39 Bytes). I can verify the

generate certificate using ECDSA in c#

左心房为你撑大大i 提交于 2019-11-26 21:56:46
问题 I'm trying to generate (self-signed) certificate with private key using ECDSA. The goals is to get "the same" (pkcs12) certificate as when using openssl: openssl ecparam -genkey -name secp256r1 -out mykey.key openssl req -new -key mykey.key -out myreq.csr openssl req -x509 -days 7 -key mykey.key -in myreq.csr -out mycert.crt openssl pkcs12 -export -out mycert.pfx -inkey mykey.key -in mycert.crt I already use BouncyCastle to help me with creating RSA-based certificate(s), so next steps more or

Does ECDiffieHellmanCng in .NET have a key derivation function that implements NIST SP 800-56A, section 5.8.1

江枫思渺然 提交于 2019-11-26 21:34:14
问题 I have a task at hand that requires deriving key material using the key derivation function described in NIST SP 800-56A, section 5.8.1. I'm not an expert in Cryptography so please excuse me if the question is naive. Here's what I've done so far: I have the other party's public key and my private key Now I try to generate the shared secret using ECDH 1.3.132.1.12 using C# (.NET 4) ECDiffieHellmanCng class like so: // The GetCngKey method reads the private key from a certificate in my Personal

Loading raw 64-byte long ECDSA public key in Java

与世无争的帅哥 提交于 2019-11-26 14:23:23
问题 I have a raw (r,s) format ECDSA NIST P-256 public key. It seems that there is no simple way to load it into an object that implements java.security.interfaces.ECPublicKey. What is the cleanest way to load a 64 byte public key so that it can be used to check signatures? 回答1: Java 7 is required for the EC functionality and Java 8 for the Base 64 encoder / decoder, no additional libraries - just plain Java. Note that this will actually display the public key as a named curve when printed out,