Ejemplo n.º 1
0
        public override byte[] CreateSignature(byte[] p_data)
        {
            if (o_hash_name == null || o_key == null)
            {
                throw new
                      CryptographicException("Qelesi dhe Hash algoritmi duhet te caktohen!");
            }
            else
            {
                HashAlgorithm x_hash_alg = HashAlgorithm.Create(o_hash_name);

                byte[] x_pkcs = ElGamalSignatureFormatHelper.CreateEMSA_PKCS1_v1_5_ENCODE(p_data, x_hash_alg, o_key.KeyStruct.P.bitCount());
                return(o_key.Sign(x_pkcs));
            }
        }
        public override bool VerifySignature(byte[] p_data, byte[] p_signature)
        {
            if (o_hash_name == null || o_key == null)
            {
                throw new
                      CryptographicException("Key and Hash Algorithm must be set");
            }
            else
            {
                // create the hashing algorithm
                HashAlgorithm x_hash_alg = HashAlgorithm.Create(o_hash_name);
                // create a PKCS1 formatted block from the data
                byte[] x_pkcs
                    = ElGamalSignatureFormatHelper.CreateEMSA_PKCS1_v1_5_ENCODE(
                          p_data, x_hash_alg, o_key.KeyStruct.P.bitCount());

                // create and return the signature
                return(o_key.VerifySignature(x_pkcs, p_signature));
            }
        }