Exemple #1
0
 public digest(array <ulong> h = default, array <byte> x = default, long nx = default, ulong len = default, crypto.Hash function = default)
 {
     this.h        = h;
     this.x        = x;
     this.nx       = nx;
     this.len      = len;
     this.function = function;
 }
Exemple #2
0
 public PSSOptions(long SaltLength = default, crypto.Hash Hash = default)
 {
     this.SaltLength = SaltLength;
     this.Hash       = Hash;
 }
Exemple #3
0
 public OAEPOptions(crypto.Hash Hash = default, slice <byte> Label = default)
 {
     this.Hash  = Hash;
     this.Label = Label;
 }
Exemple #4
0
 public cipherSuiteTLS13(ushort id = default, long keyLen = default, Func <slice <byte>, slice <byte>, aead> aead = default, crypto.Hash hash = default)
 {
     this.id     = id;
     this.keyLen = keyLen;
     this.aead   = aead;
     this.hash   = hash;
 }
Exemple #5
0
            // verifyHandshakeSignature verifies a signature against pre-hashed
            // (if required) handshake contents.
            private static error verifyHandshakeSignature(byte sigType, crypto.PublicKey pubkey, crypto.Hash hashFunc, slice <byte> signed, slice <byte> sig)
            {
                if (sigType == signatureECDSA)
                {
                    ptr <ecdsa.PublicKey> (pubKey, ok) = pubkey._ <ptr <ecdsa.PublicKey> >();
                }
                if (!ok)
                {
                    return(error.As(fmt.Errorf("expected an ECDSA public key, got %T", pubkey)) !);
                }
                if (!ecdsa.VerifyASN1(pubKey, signed, sig))
                {
                    return(error.As(errors.New("ECDSA verification failure")) !);
                }
                else if (sigType == signatureEd25519)
                {
                    (pubKey, ok) = pubkey._ <ed25519.PublicKey>();
                }
                if (!ok)
                {
                    return(error.As(fmt.Errorf("expected an Ed25519 public key, got %T", pubkey)) !);
                }
                if (!ed25519.Verify(pubKey, signed, sig))
                {
                    return(error.As(errors.New("Ed25519 verification failure")) !);
                }
                else if (sigType == signaturePKCS1v15)
                {
                    (pubKey, ok) = pubkey._ <ptr <rsa.PublicKey> >();
                }
                if (!ok)
                {
                    return(error.As(fmt.Errorf("expected an RSA public key, got %T", pubkey)) !);
                }
                {
                    var err__prev1 = err;

                    var err = rsa.VerifyPKCS1v15(pubKey, hashFunc, signed, sig);

                    if (err != null)
                    {
                        return(error.As(err) !);
                    }
                    err = err__prev1;
                }