Hi all,

I'm trying to convert a D7 program to D2009, but I get multiple AV's in this function.
Works fine in D7.

function EncryptPublicRSA(
   X           : TX509Base;
   InBuf       : Pointer;
   InSize      : Cardinal;
   OutBuf      : Pointer;
   var OutSize : Cardinal): Boolean;
var
   Len       : Word;
   PubKey    : PEVP_PKEY;
   BlockSize,
   Res       : Integer;
   InBufPtr,
   OutBufPtr : PAnsiChar;
begin
   Result  := FALSE;
   if not Assigned(X) then
       raise Exception.Create('Cert not assigned');
   PubKey := f_X509_get_pubkey(X.X509);
   if not Assigned(PubKey) then
       raise Exception.Create('Public key not assigned');
   if PubKey^.type_ <> EVP_PKEY_RSA then
       raise Exception.Create('Not a RSA key');
   BlockSize := f_EVP_PKEY_size(PubKey);      < == multiple AV's here
   { Calculate the required result buffer size }
   if InSize <= BlockSize - 11 then
       Res := BlockSize
   else
       Res := (InSize div (BlockSize - 11) + 1) * BlockSize;
   if (OutSize = 0) or (InSize = 0)or (InBuf = nil) or
      (OutBuf = nil) or (OutSize < Res) then
   begin
       OutSize := Res;
       Exit;
   end;
   InBufPtr  := InBuf;
   OutBufPtr := OutBuf;
   OutSize   := 0;
   repeat
       if InSize > BlockSize - 11 then
           Len := BlockSize - 11
       else
           Len := InSize;
       if Len > 0 then begin
           Res := f_RSA_public_encrypt(
                                       Len,
                                       InBufPtr,
                                       OutBufPtr,
                                       PubKey^.rsa,
                                       RSA_PKCS1_PADDING);
           if Res <> BlockSize then
raise Exception.Create('Error: Ciphertext should match length of key');
           Dec(InSize, Len);
           Inc(InBufPtr, Len);
           Inc(OutBufPtr, Res);
           Inc(OutSize, Res);
       end;
   until InSize = 0;
   Result := TRUE;
end;

any idea's welcome


thanks,

Paul

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to