public virtual ReadOnlyMemory <byte> MakeChecksum( ReadOnlyMemory <byte> data, KerberosKey key, KeyUsage usage, KeyDerivationMode kdf, int hashSize) { throw new NotImplementedException(); }
private byte[] DK(byte[] key, KeyUsage usage, KeyDerivationMode kdf) { var constant = new byte[5]; Endian.ConvertToBigEndian((int)usage, constant); constant[4] = (byte)kdf; return(DK(key, constant)); }
public override ReadOnlyMemory <byte> MakeChecksum( ReadOnlyMemory <byte> data, KerberosKey key, KeyUsage usage, KeyDerivationMode kdf, int hashSize ) { var ki = this.GetOrDeriveKey(key, usage, kdf).Slice(0, hashSize); return(this.Hmac(ki, data).Slice(0, hashSize)); }
public override byte[] MakeChecksum(byte[] data, byte[] key, KeyUsage usage, KeyDerivationMode kdf, int hashSize) { var ki = DK(key, usage, kdf); var hash = Hmac(ki, data); var output = new byte[hashSize]; Buffer.BlockCopy(hash, 0, output, 0, hashSize); return(output); }
public override ReadOnlyMemory <byte> MakeChecksum( ReadOnlyMemory <byte> data, KerberosKey key, KeyUsage usage, KeyDerivationMode kdf, int hashSize ) { var ki = key.GetOrDeriveKey( this, $"{usage}|{kdf}|{KeySize}|{BlockSize}", k => DK(k, usage, kdf, KeySize, BlockSize) ); return(Hmac(ki, data).Slice(0, hashSize)); }
public override ReadOnlyMemory <byte> MakeChecksum( ReadOnlyMemory <byte> data, KerberosKey key, KeyUsage usage, KeyDerivationMode kdf, int hashSize ) { if (key == null) { throw new ArgumentNullException(nameof(key)); } var ki = key.GetOrDeriveKey( this, $"{usage}|{kdf}|{this.KeySize}|{this.BlockSize}", k => DK(k, usage, kdf, this.KeySize, this.BlockSize) ); return(Hmac(ki, data).Slice(0, hashSize)); }
public virtual byte[] MakeChecksum(byte[] data, byte[] key, KeyUsage usage, KeyDerivationMode kdf, int hashSize) { throw new NotImplementedException(); }
private static ReadOnlyMemory <byte> DK(ReadOnlyMemory <byte> key, KeyUsage usage, KeyDerivationMode kdf, int keySize, int blockSize) { using (var constantPool = CryptoPool.RentUnsafe <byte>(5)) { var constant = constantPool.Memory.Slice(0, 5); Span <byte> span = constant.Span; span.Clear(); BinaryPrimitives.WriteInt32BigEndian(span, (int)usage); constant.Span[4] = (byte)kdf; return(DK(key, constant, keySize, blockSize)); } }
private static ReadOnlySpan <byte> DK(ReadOnlySpan <byte> key, KeyUsage usage, KeyDerivationMode kdf, int keySize, int blockSize) { var constant = new Span <byte>(new byte[5]); Endian.ConvertToBigEndian((int)usage, constant); constant[4] = (byte)kdf; return(DK(key, constant, keySize, blockSize)); }
private static ReadOnlyMemory <byte> DK(ReadOnlySpan <byte> key, KeyUsage usage, KeyDerivationMode kdf, int keySize, int blockSize) { using (var constantPool = CryptoPool.RentUnsafe <byte>(5)) { var constant = constantPool.Memory.Slice(0, 5); constant.Span.Fill(0); Endian.ConvertToBigEndian((int)usage, constant.Span); constant.Span[4] = (byte)kdf; return(DK(key, constant, keySize, blockSize)); } }
internal new ReadOnlyMemory <byte> GetOrDeriveKey(KerberosKey key, KeyUsage usage, KeyDerivationMode mode) { return(base.GetOrDeriveKey(key, usage, mode)); }
protected ReadOnlyMemory <byte> GetOrDeriveKey(KerberosKey kerberosKey, KeyUsage usage, KeyDerivationMode mode) { if (kerberosKey == null) { throw new InvalidOperationException("Key cannot be null"); } return(kerberosKey.GetOrDeriveKey( this, $"{usage}|{mode}|{this.KeySize}|{this.BlockSize}", key => this.DK(key, usage, mode, this.KeySize, this.BlockSize) )); }