Esempio n. 1
0
 public bool Verify(SctSignature signature)
 {
     if (signature.LogId.Length != LogId.Length || signature.LogId.Length == 0)
     {
         return false;
     }
     //verify this signature is for this log key.
     if (!signature.LogId.MemoryCompare(LogId))
     {
         return false;
     }
     SignatureVerifier verifier;
     switch (_key.KeyType)
     {
         case CtPublicKeyType.ECDSA_P256:
             if (signature.SignatureAlgorithm != SctSignatureAlgorithm.SIG_ALGO_ECDSA)
                 return false;
             verifier = new EcdsaP256SignatureVerifier(_key.Key);
             break;
         case CtPublicKeyType.RSA_PKCS15:
             if (signature.SignatureAlgorithm != SctSignatureAlgorithm.SIG_ALGO_RSA)
                 return false;
             verifier = new RsaSignatureVerifier(_key.Key);
             break;
         default:
             return false;
     }
     return verifier.Verify(new byte[0], signature.Signature, signature.HashAlgorithm);
 }
Esempio n. 2
0
        public bool Verify(SctSignature signature)
        {
            if (signature.LogId.Length != LogId.Length || signature.LogId.Length == 0)
            {
                return(false);
            }
            //verify this signature is for this log key.
            if (!signature.LogId.MemoryCompare(LogId))
            {
                return(false);
            }
            SignatureVerifier verifier;

            switch (_key.KeyType)
            {
            case CtPublicKeyType.ECDSA_P256:
                if (signature.SignatureAlgorithm != SctSignatureAlgorithm.SIG_ALGO_ECDSA)
                {
                    return(false);
                }
                verifier = new EcdsaP256SignatureVerifier(_key.Key);
                break;

            case CtPublicKeyType.RSA_PKCS15:
                if (signature.SignatureAlgorithm != SctSignatureAlgorithm.SIG_ALGO_RSA)
                {
                    return(false);
                }
                verifier = new RsaSignatureVerifier(_key.Key);
                break;

            default:
                return(false);
            }
            return(verifier.Verify(new byte[0], signature.Signature, signature.HashAlgorithm));
        }