Ejemplo n.º 1
0
            public byte[] Sign(byte[] message)
            {
                Pair <long, CardType> pair      = SmartOp.getSlotAndCardType(terminal);
                P11SmartCard          smartCard = new P11SmartCard(pair.getmObj2());

                smartCard.openSession(pair.getmObj1());
                smartCard.login(pin);
                BaseSigner signer = smartCard.getSigner(cert, Algorithms.SIGNATURE_RSA_SHA256);

                byte[] buffer = signer.sign(message);
                smartCard.logout();
                smartCard.closeSession();
                return(buffer);
            }
Ejemplo n.º 2
0
 public virtual byte[] Sign(byte[] message)
 {
     if (mSigner != null)
     {
         return(mSigner.sign(message));
     }
     if (certificate.PrivateKey is RSACryptoServiceProvider)
     {
         RSACryptoServiceProvider rsa = (RSACryptoServiceProvider)certificate.PrivateKey;
         return(rsa.SignData(message, hashAlgorithm));
     }
     else
     {
         DSACryptoServiceProvider dsa = (DSACryptoServiceProvider)certificate.PrivateKey;
         return(dsa.SignData(message));
     }
 }