Пример #1
0
        private byte[] BuildSecretAppend(JwtElement apuS, JwtElement apvS)
        {
            var apu = apuS.IsEmpty ? default : apuS.GetRawValue();

                      var                           apv       = apvS.IsEmpty ? default : apvS.GetRawValue();
                                                int apuLength = Base64Url.GetArraySizeRequiredToDecode(apu.Length);
                                                int apvLength = Base64Url.GetArraySizeRequiredToDecode(apv.Length);

                                                int       algorithmLength   = sizeof(int) + _algorithmNameLength;
                                                int       partyUInfoLength  = sizeof(int) + apuLength;
                                                int       partyVInfoLength  = sizeof(int) + apvLength;
                                                const int suppPubInfoLength = sizeof(int);

                                                int secretAppendLength = algorithmLength + partyUInfoLength + partyVInfoLength + suppPubInfoLength;
                                                var secretAppend       = new byte[secretAppendLength];
                                                var secretAppendSpan   = secretAppend.AsSpan(0, secretAppendLength);

                                                WriteAlgorithmId(secretAppendSpan);
                                                secretAppendSpan = secretAppendSpan.Slice(algorithmLength);
                                                WritePartyInfo(apu.Span, apuLength, secretAppendSpan);
                                                secretAppendSpan = secretAppendSpan.Slice(partyUInfoLength);
                                                WritePartyInfo(apv.Span, apvLength, secretAppendSpan);
                                                secretAppendSpan = secretAppendSpan.Slice(partyVInfoLength);
                                                BinaryPrimitives.WriteInt32BigEndian(secretAppendSpan, _keySizeInBytes << 3);

                                                return(secretAppend);
        }
Пример #2
0
            internal ObjectEnumerator(JwtElement target)
            {
                _curIdx = -1;

                var value = target.GetRawValue();
                int count = target.GetMemberCount();

                if (!TryParse(value, target.GetMemberCount(), out _document !))
                {
                    ThrowHelper.ThrowFormatException_MalformedJson();
                }

                Debug.Assert(target.TokenType == JsonTokenType.StartObject);
                _endIdxOrVersion = count * JsonRow.Size * 2;
            }