private static ushort GetMaskedVersion(ushort version, VersionMaskType versionMaskType) { if (versionMaskType == VersionMaskType.None) { return version; } else { return (ushort)(0xFFFF - version); } }
private static ushort GetMaskedVersion(ushort version, VersionMaskType versionMaskType) { if (versionMaskType == VersionMaskType.None) { return(version); } else { return((ushort)(0xFFFF - version)); } }
/// <summary> /// Creates a new <see cref="RollingIv"/> instance. /// </summary> /// <param name="initialIv">The initial IV for the new instance.</param> /// <param name="versionMaskType">The <see cref="VersionMaskType"/> for the new instance.</param> /// <returns>a new instance of <see cref="RollingIv"/>.</returns> public RollingIv CreateEncryptIv(byte[] initialIv, VersionMaskType versionMaskType) { ushort versionMask = GetMaskedVersion(this.version, versionMaskType); return new RollingIv(this.encryptionAlgorithm, initialIv, versionMask); }
/// <summary> /// Creates a new <see cref="RollingIv"/> instance. /// </summary> /// <param name="initialIv">The initial IV for the new instance.</param> /// <param name="versionMaskType">The <see cref="VersionMaskType"/> for the new instance.</param> /// <returns>a new instance of <see cref="RollingIv"/>.</returns> public RollingIv CreateDecryptIv(byte[] initialIv, VersionMaskType versionMaskType) { ushort versionMask = GetMaskedVersion(_version, versionMaskType); return(new RollingIv(_decryptionAlgorithm, initialIv, versionMask)); }