コード例 #1
0
        public byte[] Expand(
            ReadOnlySpan <byte> pseudorandomKey,
            ReadOnlySpan <byte> info,
            int count)
        {
            if (pseudorandomKey.Length < crypto_auth_hmacsha512_BYTES)
            {
                throw Error.Argument_InvalidPrkLength(nameof(pseudorandomKey), crypto_auth_hmacsha512_BYTES.ToString());
            }
            if (count < 0)
            {
                throw Error.ArgumentOutOfRange_DeriveNegativeCount(nameof(count));
            }
            if (count > MaxOutputSize)
            {
                throw Error.ArgumentOutOfRange_DeriveInvalidCount(nameof(count), MaxOutputSize.ToString());
            }
            if (count == 0)
            {
                return(new byte[0]);
            }

            byte[] bytes = new byte[count];
            ExpandCore(pseudorandomKey, info, bytes);
            return(bytes);
        }
コード例 #2
0
        public override string ToString()
        {
            return(string.Format(CultureInfo.CurrentCulture,
                                 "VIDEO_STREAM_CONFIG_CAPS -  guid: {0},  VideoStandard: {1},  " +
                                 "InputSize: {2},  " +
                                 "MinCroppingSize: {3},  MaxCroppingSize: {4},  " +
                                 "CropGranularityX: {5},  CropGranularityY: {6},  " +
                                 "CropAlignX: {7},  CropAlignY: {8},  " +
                                 "MinOutputSize: {9},  MaxOutputSize: {10},  " +
                                 "OutputGranularityX: {11},  OutputGranularityY: {12},  " +
                                 "StretchTapsX: {13},  StretchTapsY: {14},  " +
                                 "ShrinkTapsX: {15},  ShrinkTapsY: {16},  " +
                                 "MinFrameInterval: {17},  MaxFrameInterval: {18},  " +
                                 "MinBitsPerSecond: {19},  MaxBitsPerSecond: {20}",

                                 // Docs clearly say this is a format type
                                 MediaType.FormatType.GuidToString(guid), VideoStandard,
                                 InputSize.ToString(),
                                 MinCroppingSize.ToString(), MaxCroppingSize.ToString(),
                                 CropGranularityX, CropGranularityY,
                                 CropAlignX, CropAlignY,
                                 MinOutputSize.ToString(), MaxOutputSize.ToString(),
                                 OutputGranularityX, OutputGranularityY,
                                 StretchTapsX, StretchTapsY,
                                 ShrinkTapsX, ShrinkTapsY,
                                 MinFrameInterval, MaxFrameInterval,
                                 MinBitsPerSecond, MaxBitsPerSecond));
        }
コード例 #3
0
        public void Expand(
            ReadOnlySpan <byte> pseudorandomKey,
            ReadOnlySpan <byte> info,
            Span <byte> bytes)
        {
            if (pseudorandomKey.Length < crypto_auth_hmacsha256_BYTES)
            {
                throw Error.Argument_InvalidPrkLength(nameof(pseudorandomKey), crypto_auth_hmacsha256_BYTES.ToString());
            }
            if (bytes.Length > MaxOutputSize)
            {
                throw Error.Argument_DeriveInvalidCount(nameof(bytes), MaxOutputSize.ToString());
            }
            if (Utilities.Overlap(bytes, pseudorandomKey))
            {
                throw Error.Argument_OverlapPrk(nameof(bytes));
            }
            if (Utilities.Overlap(bytes, info))
            {
                throw Error.Argument_OverlapInfo(nameof(bytes));
            }
            if (bytes.IsEmpty)
            {
                return;
            }

            ExpandCore(pseudorandomKey, info, bytes);
        }
コード例 #4
0
ファイル: HkdfSha512.cs プロジェクト: dustinsoftware/nsec
        internal /*public*/ void Expand(
            ReadOnlySpan <byte> pseudorandomKey,
            ReadOnlySpan <byte> info,
            Span <byte> bytes)
        {
            if (pseudorandomKey.Length < crypto_auth_hmacsha512_BYTES)
            {
                throw Error.Argument_InvalidPrkLength(nameof(pseudorandomKey), crypto_auth_hmacsha512_BYTES.ToString());
            }
            if (bytes.Length > MaxOutputSize)
            {
                throw Error.Argument_DeriveInvalidCount(nameof(bytes), MaxOutputSize.ToString());
            }
            if (bytes.Overlaps(pseudorandomKey))
            {
                throw Error.Argument_OverlapPrk(nameof(bytes));
            }
            if (bytes.Overlaps(info))
            {
                throw Error.Argument_OverlapInfo(nameof(bytes));
            }

            ExpandCore(pseudorandomKey, info, bytes);
        }