private static IAsymmetricCryptoAlgorithm GetAsymmetricAlgorithm(this AsymmetricAlgorithmName name,
                                                                         AsymmetricAlgorithmKey keySize)
        {
            switch (name)
            {
            case AsymmetricAlgorithmName.ElGamal:
                return(new ElGamal(keySize: (int)keySize));

                break;

            case AsymmetricAlgorithmName.RSA:
            default:
                return(new RSA(keySize: (int)keySize));

                break;
            }
        }
Esempio n. 2
0
 public SignatureOutputViewModel(byte[] signature, HashAlgorithmName hash, AsymmetricAlgorithmName alg,
                                 AsymmetricAlgorithmKey algKey, string file)
 {
     this.Description = "Signature";
     this.Signature   = signature.ConvertToHex();
     this.Methods     = new List <string>()
     {
         hash.ToString(),
             alg.ToString()
     };
     this.Method     = string.Join("\n", Methods);
     this.KeyLengths = new List <string>()
     {
         "0A",
         ((int)algKey).ToString("X")  // hex
     };
     this.KeyLength = string.Join("\n", KeyLengths);
     this.FileName  = file;
 }
 public EnvelopeOutputViewModel(byte[] data, byte[] key, SymmetricAlgorithmName sym,
                                SymmetricAlgorithmKey symKey, AsymmetricAlgorithmName alg, AsymmetricAlgorithmKey algKey, string file)
 {
     this.Description      = "Envelope";
     this.EnvelopeData     = Convert.ToBase64String(data);
     this.EnvelopeCryptKey = key.ConvertToHex();
     this.Methods          = new List <string>()
     {
         sym.ToString(),
             alg.ToString()
     };
     this.Method     = string.Join("\n", Methods);
     this.KeyLengths = new List <string>()
     {
         ((int)symKey).ToString("X"), // hex
         ((int)algKey).ToString("X")  // hex
     };
     this.KeyLength = string.Join("\n", KeyLengths);
     this.FileName  = file;
 }