public static void Ctor() { var actual = new Nonce(); Assert.Equal(0, actual.Size); Assert.Equal(0, actual.FixedFieldSize); Assert.Equal(0, actual.CounterFieldSize); Assert.Equal(Array.Empty <byte>(), actual.ToArray()); Assert.Equal("[][]", actual.GetDebuggerDisplay()); actual.CopyTo(Span <byte> .Empty); }
public static void Ctor() { var actual = new Nonce(); Assert.Equal(0, actual.Size); Assert.Equal(0, actual.FixedFieldSize); Assert.Equal(0, actual.CounterFieldSize); Assert.Equal(new byte[0], actual.ToArray()); Assert.Equal("[][]", actual.ToString()); actual.CopyTo(Span <byte> .Empty); }
public static void CtorWithCounterSize(int size) { var expected = new byte[size]; var actual = new Nonce(0, size); var array = new byte[expected.Length]; Assert.Equal(expected.Length, actual.Size); Assert.Equal(0, actual.FixedFieldSize); Assert.Equal(expected.Length, actual.CounterFieldSize); Assert.Equal(expected, actual.ToArray()); Assert.Equal("[][" + expected.EncodeHex() + "]", actual.GetDebuggerDisplay()); actual.CopyTo(array); Assert.Equal(expected, array); }
public static void CtorWithCounterSize(int size) { var expected = new byte[size]; var actual = new Nonce(0, size); var array = new byte[expected.Length]; Assert.Equal(expected.Length, actual.Size); Assert.Equal(0, actual.FixedFieldSize); Assert.Equal(expected.Length, actual.CounterFieldSize); Assert.Equal(expected, actual.ToArray()); Assert.Equal("[][" + Base16.Encode(expected) + "]", actual.ToString()); Assert.Equal(expected.Length, actual.CopyTo(array)); Assert.Equal(expected, array); }
public static void CtorWithFixedAndCounterSize(int size) { var fixedField = Utilities.RandomBytes.Slice(0, size / 2).ToArray(); var counterField = new byte[size - fixedField.Length]; var expected = new byte[size]; var actual = new Nonce(fixedField, counterField.Length); var array = new byte[expected.Length]; fixedField.CopyTo(expected, 0); Assert.Equal(expected.Length, actual.Size); Assert.Equal(fixedField.Length, actual.FixedFieldSize); Assert.Equal(counterField.Length, actual.CounterFieldSize); Assert.Equal(expected, actual.ToArray()); Assert.Equal("[" + fixedField.EncodeHex() + "][" + counterField.EncodeHex() + "]", actual.GetDebuggerDisplay()); actual.CopyTo(array); Assert.Equal(expected, array); }
public static void CtorWithFixedAndCounterSize(int size) { var fixedField = Utilities.RandomBytes.Slice(0, size / 2); var counterField = new byte[size - fixedField.Length]; var expected = new byte[size]; var actual = new Nonce(fixedField, counterField.Length); var array = new byte[expected.Length]; fixedField.CopyTo(expected); Assert.Equal(expected.Length, actual.Size); Assert.Equal(fixedField.Length, actual.FixedFieldSize); Assert.Equal(counterField.Length, actual.CounterFieldSize); Assert.Equal(expected, actual.ToArray()); Assert.Equal("[" + Base16.Encode(fixedField) + "][" + Base16.Encode(counterField) + "]", actual.ToString()); Assert.Equal(expected.Length, actual.CopyTo(array)); Assert.Equal(expected, array); }
public byte[] GetNonceBytes(Nonce nonce) { Byte[] nonceBytes = new Byte[12]; nonce.CopyTo(nonceBytes); return(nonceBytes); }