Windows error 0x80090004, -2146893820

Detailed Error Information

NTE_BAD_LEN[1]

MessageBad Length.
Declared inwinerror.h

HRESULT analysis[2]

FlagsSeverityFailure
Reserved (R)false
OriginMicrosoft
NTSTATUSfalse
Reserved (X)false
FacilityCode9 (0x009)
NameFACILITY_SSPI[2][1]
DescriptionThe source of the error code is the Security API layer.[2][1]
Error Code4 (0x0004)

Questions

3votes
1answer

Error importing public key using cryptoapi CryptImportKey

I want to import public key blob to a CSP. but error occurred. BYTE pbData[] ={0xEB,0x2A,0x38,0x56,0x86,0x61,0x88,0x7F,0xA1,0x80,0xBD,0xDB,0x5C,0xAB,0xD5,0xF2,0x1C,0x7B,0xFD,0x59,0xC0,0x90,0xCB,0x2D,0x24,0x5A,0x87,0xAC,0x25,0x30,0x62,0x88,0x27,0x29,0x29,0x3E,0x55,0x06,0x35,0x05,0x08,0xE7,0xF9,0xAA,0x3B,0xB7,0x7F,0x43,0x33,0x23,0x14,0x90,0xF9,0x15,0xF6,0xD6,0x3C,0x55,0xFE,0x2F,0x08,0xA4,0x9B,0x35,0x3F,0x44,0x4A,0xD3,0x99,0x3C,0xAC,0xC0,0x2D,0xB7,0x84,0xAB,0xBB,0x8E,0x42,0xA9,0xB1,0xBB,0xFF,0xFB,0x38,0xBE,0x18,0xD7,0x8E,0x87,0xA0,0xE4,0x1B,0x9B,0x8F,0x73,0xA9,0x28,0xEE,0x0C,0xCE,0xE1,0xF6,0x73,0x98,0x84,0xB9,0x77,0x7E,0x4F,0xE9,0xE8,0x8A,0x1B,0xBE,0x49,0x59,0x27,0xAC,0x4A,0x79,0x9B,0x31,0x81,0xD6,0x44,0x24,0x43}; USHORT modulusLengthInBytes = sizeof(pbData); HCRYPTKEY hPublicKey; DWORD keyBlobLength = sizeof(BLOBHEADER)+sizeof(RSAPUBKEY)+modulusLengthInBytes; BYTE* keyBlob = (BYTE*)malloc(keyBlobLength); BLOBHEADER* blobheader = (BLOBHEADER*) keyBlob; blobheader->bType = PUBLICKEYBLOB; blobheader->bVersion = CUR_BLOB_VERSION; blobheader->reserved = 0; blobheader->aiKeyAlg = CALG_RSA_KEYX; RSAPUBKEY* rsapubkey = [...] read more
c
winapi
rsa
public-key-encryption
cryptoapi
1vote
0answers

CryptEncrypt fails with NTE_BAD_LEN

I need to encrypt message with X.509 RSA public key. I successfully imported 1024-bit public key in DER format, but my program fails with message longer than about 110 bytes. I'm calling CryptEncrypt function with pbData set to NULL, because I need to calculate size of output buffer first. This [...] read more
winapi
rsa
public-key-encryption
cryptoapi
x509
0votes
0answers

VB.Net RSA Encrypting text using a given public key with RSACryptoServiceProvider is not possible

Well, there is so many examples, but no luck with any of them. Here is my code first: Imports System.Security.Cryptography Imports Org.BouncyCastle.Asn1 Imports Org.BouncyCastle.Crypto.Parameters Imports Org.BouncyCastle.Security Public Class Form1 Dim works = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0 FPqri0cb2JZfXJ/DgYSF6vUpwmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/ 3j+skZ6UtW+5u09lHNsj6tQ51s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQAB" Dim dont = "MDwwDQYJKoZIhvcNAQEBBQADKwAwKAIhAJhEArIWom9n7PBxEbRsQC/PGV03t+bGudrio9E1Jje5AgMBAAE=" Public Shared Function ImportFromKey(ByVal secret_key As String) As RSACryptoServiceProvider Dim obj [...] read more
.net
vb.net
encryption
cryptography
rsa

Comments

Leave a comment

(plain text only)

Sources

  1. winerror.h from Windows SDK 10.0.14393.0
  2. https://msdn.microsoft.com/en-us/library/cc231198.aspx

User contributions licensed under CC BY-SA 3.0