You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by bl...@apache.org on 2004/10/02 02:37:13 UTC

cvs commit: xml-security/c/src/enc/WinCAPI WinCAPICryptoKeyRSA.cpp

blautenb    2004/10/01 17:37:13

  Modified:    c/src/enc/WinCAPI WinCAPICryptoKeyRSA.cpp
  Log:
  Fix endian input/output problem in windows crypto api RSA imp
  
  Revision  Changes    Path
  1.8       +13 -2     xml-security/c/src/enc/WinCAPI/WinCAPICryptoKeyRSA.cpp
  
  Index: WinCAPICryptoKeyRSA.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/enc/WinCAPI/WinCAPICryptoKeyRSA.cpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- WinCAPICryptoKeyRSA.cpp	8 Feb 2004 10:23:33 -0000	1.7
  +++ WinCAPICryptoKeyRSA.cpp	2 Oct 2004 00:37:13 -0000	1.8
  @@ -505,8 +505,11 @@
   			"WinCAPI:RSA - Attempt to decrypt data with empty key");
   	}
   
  +	// Have to reverse ordering of input :
   	DWORD decryptSize = inLength;
  -	memcpy(plainBuf, inBuf, inLength);
  +	// memcpy(plainBuf, inBuf, inLength);
  +	for (unsigned int i = 0; i < inLength; ++i)
  +		plainBuf[i] = inBuf[inLength - 1 - i];
   
   	switch (padding) {
   
  @@ -631,6 +634,14 @@
   
   	}
   
  +	// Reverse the output
  +	unsigned char *tbuf;
  +	XSECnew(tbuf, unsigned char[encryptSize]);
  +	ArrayJanitor<unsigned char> j_tbuf(tbuf);
  +	memcpy(tbuf, cipherBuf, encryptSize);
  +
  +	for (unsigned int i = 0; i < encryptSize; ++i)
  +		cipherBuf[i] = tbuf[encryptSize - 1 - i];
   
   	return encryptSize;