anchor.diff:      if Result then
         RSA_Free(LRsa);
     finally
  -    BIO_free(LPubKeyBIO);
  +    BIO_free(LPubKeyBIO);
     end;
   end;
   
  
positive.code: {******************************************************************************}
  {                                                                              }
  {  Delphi JOSE Library                                                         }
  {  Copyright (c) 2015-2017 Paolo Rossi                                         }
  {  https://github.com/paolo-rossi/delphi-jose-jwt                              }
  {                                                                              }
  {******************************************************************************}
  {                                                                              }
  {  Licensed under the Apache License, Version 2.0 (the "License");             }
  {  you may not use this file except in compliance with the License.            }
  {  You may obtain a copy of the License at                                     }
  {                                                                              }
  {      http://www.apache.org/licenses/LICENSE-2.0                              }
  {                                                                              }
  {  Unless required by applicable law or agreed to in writing, software         }
  {  distributed under the License is distributed on an "AS IS" BASIS,           }
  {  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.    }
  {  See the License for the specific language governing permissions and         }
  {  limitations under the License.                                              }
  {                                                                              }
  {******************************************************************************}
  
  unit JOSE.Signing.RSA;
  
  interface
  
  uses
    System.SysUtils,
    IdGlobal,
    IdCTypes,
    IdSSLOpenSSLHeaders,
    JOSE.Encoding.Base64;
  
  type
    TRSAAlgorithm = (RS256, RS384, RS512);
    TRSAAlgorithmHelper = record helper for TRSAAlgorithm
      procedure FromString(const AValue: string);
      function ToString: string;
    end;
  
    TRSA = class
    private
      const PKCS1_SIGNATURE_PUBKEY: RawByteString = '-----BEGIN RSA PUBLIC KEY-----';
      class var FOpenSSLHandle: HMODULE;
      class var _PEM_read_bio_RSA_PUBKEY: function(bp : PBIO; x : PPRSA; cb : ppem_password_cb; u: Pointer) : PRSA cdecl;
      class var _EVP_MD_CTX_create: function: PEVP_MD_CTX cdecl;
      class var _EVP_MD_CTX_destroy: procedure(ctx: PEVP_MD_CTX); cdecl;
      class procedure LoadOpenSSL;
    public
      class function Sign(const AInput, AKey: TBytes; AAlg: TRSAAlgorithm): TBytes;
      class function Verify(const AInput, ASignature, AKey: TBytes; AAlg: TRSAAlgorithm): Boolean;
      class function VerifyPublicKey(const AKey: TBytes): Boolean;
      class function VerifyPrivateKey(const AKey: TBytes): Boolean;
    end;
  
  implementation
  
  function ArrayToString(const ASource: array of char): string;
  var
    LSourcePointer: PChar;
    LTarget: string;
  
negative.code:   end;
  end;
  
  class function TRSA.VerifyPrivateKey(const AKey: TBytes): Boolean;
  var
    LPubKeyBIO: pBIO;
    LRsa: pRSA;
  begin
    LoadOpenSSL;
  
    // Load Public RSA Key
  