public virtual void SignAndVerifyHash(ECParameters parameters) { byte[] hash, signature; using (var algorithm = Create(parameters)) { hash = CryptoUtils.GenerateRandomBytes(algorithm.KeySize / 8); signature = algorithm.SignHash(hash); } Assert.True(VerifyHash(parameters, hash, signature)); }
/// <summary> /// Initializes a new instance of the <see cref="CMACGrasshopper"/> class. /// </summary> public CMACGrasshopper() : this(CryptoUtils.GenerateRandomBytes(32)) { }
/// <summary> /// Generates a random key to be used for the algorithm. /// </summary> public override void GenerateKey() { KeyValue = CryptoUtils.GenerateRandomBytes(KeySizeValue / 8); }
/// <summary> /// Generates a random initialization vector to be used for the algorithm. /// </summary> public override void GenerateIV() { IVValue = CryptoUtils.GenerateRandomBytes(FeedbackSizeValue / 8); }
/// <summary> /// Initializes a new instance of the <see cref="HMACStreebog512"/> /// class with a randomly generated key. /// </summary> public HMACStreebog512() : this(CryptoUtils.GenerateRandomBytes(64)) { }
/// <summary> /// Initializes a new instance of the <see cref="CMACMagma"/> class. /// </summary> public CMACMagma() : this(CryptoUtils.GenerateRandomBytes(32)) { }