예제 #1
0
        private static void WriteHintName(byte[] buffer, ref int offset, string hintName)
        {
            byte[] hintNameBytes      = DerEncodingHelper.EncodeGeneralString(hintName);
            int    constructionLength = 1 + DerEncodingHelper.GetLengthFieldSize(hintNameBytes.Length) + hintNameBytes.Length;

            ByteWriter.WriteByte(buffer, ref offset, HintNameTag);
            DerEncodingHelper.WriteLength(buffer, ref offset, constructionLength);
            ByteWriter.WriteByte(buffer, ref offset, (byte)DerEncodingTag.GeneralString);
            DerEncodingHelper.WriteLength(buffer, ref offset, hintNameBytes.Length);
            ByteWriter.WriteBytes(buffer, ref offset, hintNameBytes);
        }
예제 #2
0
        protected static int GetHintsSequenceLength(string hintName, byte[] hintAddress)
        {
            int sequenceLength = 0;

            if (hintName != null)
            {
                byte[] hintNameBytes               = DerEncodingHelper.EncodeGeneralString(hintName);
                int    lengthFieldSize             = DerEncodingHelper.GetLengthFieldSize(hintNameBytes.Length);
                int    constructionLength          = 1 + lengthFieldSize + hintNameBytes.Length;
                int    constructionLengthFieldSize = DerEncodingHelper.GetLengthFieldSize(constructionLength);
                int    entryLength = 1 + constructionLengthFieldSize + 1 + lengthFieldSize + hintNameBytes.Length;
                sequenceLength += entryLength;
            }
            if (hintAddress != null)
            {
                int lengthFieldSize             = DerEncodingHelper.GetLengthFieldSize(hintAddress.Length);
                int constructionLength          = 1 + lengthFieldSize + hintAddress.Length;
                int constructionLengthFieldSize = DerEncodingHelper.GetLengthFieldSize(constructionLength);
                int entryLength = 1 + constructionLengthFieldSize + 1 + lengthFieldSize + hintAddress.Length;
                sequenceLength += entryLength;
            }
            return(sequenceLength);
        }