[cc'ing the mailing list in case anyone else runs into this]

 

You're right, the NULL value is optional, and the Crypto++ isn't handling it 
correctly. The fix is to change this line in PKCS8PrivateKey::BERDecode:



   bool parametersPresent = BERDecodeAlgorithmParameters(algorithm);


to:



   bool parametersPresent = algorithm.EndReached() ? false : 
BERDecodeAlgorithmParameters(algorithm);



Thanks for reporting this problem, and let me know if that fixes it.

  ----- Original Message ----- 
  From: çagdas cirit 
  To: [EMAIL PROTECTED] 
  Sent: Monday, January 22, 2007 7:55 PM
  Subject: Thank you very much


  Dear Sir,

  Thank you very much for your help;

  The file is not hex encoded, so why do you use HexDecoder? Just do

   FileSource privFile("d:\\pPrivateKeyBuf.bin", true);


  Our problem is not about HexEncoding or Decoding but your answer gave a clue 
about our problem and i solved the problem; 
  In our PFX files Rsa Private Key skeleton is alittle bit different, when you 
look at our key file with an asn1 viewer you will see we do not add an 
attribute in PrivateKeyAlgorithmIdentifier ; (after algorithm OID) 
algorithmParameters. If there is no parameter we do not add an attribute with 
NULL value, we just ignore it.

  But crypto++ need to know if there is any parameter; true or false and we get 
an error at the step ; 

  --asn.cpp--


void PKCS8PrivateKey::
BERDecode(BufferedTransformation &
bt){    BERSequenceDecoder 
privateKeyInfo(bt);             
word32 version;         
BERDecodeUnsigned<word32>(
privateKeyInfo, version, 
INTEGER, 0, 0); // check version                BERSequenceDecoder
 algorithm(
privateKeyInfo);                        GetAlgorithmID().
BERDecodeAndCheck(algorithm);                   bool 
parametersPresent = BERDecodeAlgorithmParameters(
algorithm); <=== at his step we get an BerDecodeError
                algorithm.
MessageEnd();           BERGeneralDecoder 
octetString(privateKeyInfo, 
OCTET_STRING);                  BERDecodeKey2(
octetString, parametersPresent, 
privateKeyInfo.RemainingLength());              
octetString.MessageEnd();               
BERDecodeOptionalAttributes(privateKeyInfo);    
privateKeyInfo.MessageEnd();}void 
BERDecodeNull(BufferedTransformation &
in){    byte 
b;      if (!in.
Get(b) || b
 != TAG_NULL)           
BERDecodeError(); <=== here we get error        unsigned int 
length; if (!BERLengthDecode(
in, length) || 
length != 0)            BERDecodeError();}And now i want to ask you one 
important question; 

  Is there a configuration to skip algorithParameter check step? or Should we 
add this parameter to our Pfx files?

  Again and again thank you very much...

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [EMAIL PROTECTED]
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

Reply via email to