ecdsa

Converting P1363 format to ASN.1/DER format using Java

此生再无相见时 提交于 2020-06-17 09:45:07
问题 BackGround I have a server which uses MSRCrypto to sign my nonce. I need to verify that nonce in Java. It is well know that MSRCrypto sends it in P1363 format and Java Library requires it in DER format. I cannot change the server code as I am the client. The server is using SHA386withECDSA What I need 1) Can someone provide me with exact code snippet to convert it from P1363 format to ASN.1 and vice-versa(ASN.1 to P1363) in Java . I tried a few code snippets but was not able to make it work

C# BouncyCastle PKCS#8

邮差的信 提交于 2020-04-18 06:10:42
问题 I want load the PEM using .net framework (not .netcore) -----BEGIN ENCRYPTED PRIVATE KEY----- MIHs........................................................CAAw DAYI........................................................gZAf Y/Iu........................................................X7DZ ZKoE........................................................OYQQ 3ZST........................................................A2E= -----END ENCRYPTED PRIVATE KEY----- I tried to use the following code using

How to export EC private key as PKCS#1 or PKCS#8 format from certificate store by CNG?

二次信任 提交于 2020-04-18 05:47:56
问题 I tried to export private key from certificate store by CNG API. It work fine when export RSA private key, but failed in EC private key. The code failed in NCryptExportKey() with 0x80090029 . Is there any document from MS said: Export EC private key not support? or any sample code? Here is my code: NCRYPT_KEY_HANDLE hKey = NULL; SECURITY_STATUS secStatus = ERROR_SUCCESS; NTSTATUS status = STATUS_UNSUCCESSFUL; DWORD dwKeySpec, cbData = 0, cbBlob = 0, KeyPolicy = 0; PBYTE pbHash = NULL, pbBlob

Is python-ecdsa signature size correct?

与世无争的帅哥 提交于 2020-04-11 05:03:23
问题 On the bitcoin wiki I found that bitcoin uses the ECDSA algorithm with the Secp256k1 curve. Relevant Links: https://en.bitcoin.it/wiki/Elliptic_Curve_Digital_Signature_Algorithm https://en.bitcoin.it/wiki/Secp256k1 On the first link, it says private key should be 32 bytes, public key 64 bytes, and the signature typically between 71-73 bytes. It says the signature can be smaller with small probability. However, when I run the following python3 code >>> from ecdsa import SigningKey, SECP256k1 >

What is the output format of the SHA256withECDSA signature algorithm?

∥☆過路亽.° 提交于 2020-03-05 02:56:25
问题 I'm generating a key pair using the secp256k1 curve. Then I'm using the private key to sign a random String: byte[] content = "random string".getBytes(); Signature dsa = Signature.getInstance("SHA256withECDSA"); dsa.initSign(privateKey); dsa.update(content); byte[] signature = dsa.sign(); The signature byte array has the following content: [48, 68, 2, 32, 11, 25, 119, -64, -107, 53, -84, 65, -18, -81, -56, 34, 11, 29, 120, 38, -102, 105, -89, -9, -46, -28, 91, 59, -74, -103, -53, 117, 81, -37

Java Exception during signature verification (error decoding signature bytes)

好久不见. 提交于 2020-03-04 07:11:48
问题 I have to verify a certificate. I'm not an expert of cryptography, so probably I did something (or everything :) ) wrong. When the code reach the last step ( boolean b = sig.verify(CertSign); ), it fires an exception: java.security.SignatureException: error decoding signature bytes . Could someone help me to figure out what I'm doing wrong? The following is a test code that shows the problem: private void test() { byte [] CertBody = new byte[]{(byte)0x7F,(byte)0x4E,(byte)0x81,(byte)0x82,

Java Exception during signature verification (error decoding signature bytes)

瘦欲@ 提交于 2020-03-04 07:11:12
问题 I have to verify a certificate. I'm not an expert of cryptography, so probably I did something (or everything :) ) wrong. When the code reach the last step ( boolean b = sig.verify(CertSign); ), it fires an exception: java.security.SignatureException: error decoding signature bytes . Could someone help me to figure out what I'm doing wrong? The following is a test code that shows the problem: private void test() { byte [] CertBody = new byte[]{(byte)0x7F,(byte)0x4E,(byte)0x81,(byte)0x82,

How to sign using ECDSA in Javacard

浪尽此生 提交于 2020-02-25 07:44:20
问题 I'm trying to implement the signing code using ECDSA. But I always get a Error SW (6F00) during install phase. I tried by changing parameters several times. (ex. ALG_EC_FP / ALG_EC_F2M, LENGTH_EC_FP_xxx / LENGTH_EC_F2M_xxx) Could you tell me my mistake in my code below. (Ver - JCDK 2.2.1, JDK 1.4.2) package Test; import javacard.framework.*; import javacard.security.*; import javacardx.crypto.*; public class Test extends Applet{ private byte[] PLAINTEXT ; private ECPrivateKey objECDSAPriKey

Can't get ECDSA signature to validate with public key

∥☆過路亽.° 提交于 2020-01-24 22:12:29
问题 I'm running out of ideas as to why my sample code won't verify the given EC public key, signature and message. I've converted the signature to ASN.1 format which is 70 bytes and the public key is 64 bytes plus uncompressed byte (0x04). I've also tried converting the message to SHA256 hash but that didn't work as well. The publicKey hex value is used to construct a ECPublicKey with prime256v1 curve. The signature is base64 decoded then formatted to ASN.1. I don't see what I could be doing