17a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root/* 27a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root * Copyright (C) 2013 The Android Open Source Project 37a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root * 47a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root * Licensed under the Apache License, Version 2.0 (the "License"); 57a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root * you may not use this file except in compliance with the License. 67a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root * You may obtain a copy of the License at 77a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root * 87a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root * http://www.apache.org/licenses/LICENSE-2.0 97a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root * 107a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root * Unless required by applicable law or agreed to in writing, software 117a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root * distributed under the License is distributed on an "AS IS" BASIS, 127a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 137a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root * See the License for the specific language governing permissions and 147a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root * limitations under the License. 157a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root */ 167a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root 17861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao#include <stdint.h> 18861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 19861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao#include <memory> 207a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root 217a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root#include <gtest/gtest.h> 227a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root 237a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root#include "asn1_decoder.h" 247a4adb5268ae71260c86788ccdeb7a699c80ee0aKenny Root 25861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, Empty_Failure) { 26861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t empty[] = {}; 27861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(empty, sizeof(empty)); 28861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 29861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(nullptr, ctx.asn1_constructed_get()); 30861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_FALSE(ctx.asn1_constructed_skip_all()); 31861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(0, ctx.asn1_constructed_type()); 32861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(nullptr, ctx.asn1_sequence_get()); 33861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(nullptr, ctx.asn1_set_get()); 34861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_FALSE(ctx.asn1_sequence_next()); 35861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 36861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao const uint8_t* junk; 37861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao size_t length; 38861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_FALSE(ctx.asn1_oid_get(&junk, &length)); 39861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_FALSE(ctx.asn1_octet_string_get(&junk, &length)); 40861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 41861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 42861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, ConstructedGet_TruncatedLength_Failure) { 43861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t truncated[] = { 0xA0, 0x82 }; 44861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(truncated, sizeof(truncated)); 45861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(nullptr, ctx.asn1_constructed_get()); 46861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 47861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 48861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, ConstructedGet_LengthTooBig_Failure) { 49861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t truncated[] = { 0xA0, 0x8a, 0xA5, 0x5A, 0xA5, 0x5A, 0xA5, 0x5A, 0xA5, 0x5A, 0xA5, 0x5A }; 50861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(truncated, sizeof(truncated)); 51861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(nullptr, ctx.asn1_constructed_get()); 52861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 53861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 54861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, ConstructedGet_TooSmallForChild_Failure) { 55861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t data[] = { 0xA5, 0x02, 0x06, 0x01, 0x01 }; 56861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(data, sizeof(data)); 57861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao std::unique_ptr<asn1_context> ptr(ctx.asn1_constructed_get()); 58861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_NE(nullptr, ptr); 59861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(5, ptr->asn1_constructed_type()); 60861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao const uint8_t* oid; 61861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao size_t length; 62861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_FALSE(ptr->asn1_oid_get(&oid, &length)); 63861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 64861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 65861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, ConstructedGet_Success) { 66861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t data[] = { 0xA5, 0x03, 0x06, 0x01, 0x01 }; 67861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(data, sizeof(data)); 68861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao std::unique_ptr<asn1_context> ptr(ctx.asn1_constructed_get()); 69861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_NE(nullptr, ptr); 70861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(5, ptr->asn1_constructed_type()); 71861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao const uint8_t* oid; 72861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao size_t length; 73861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_TRUE(ptr->asn1_oid_get(&oid, &length)); 74861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(1U, length); 75861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(0x01U, *oid); 76861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 77861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 78861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, ConstructedSkipAll_TruncatedLength_Failure) { 79861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t truncated[] = { 0xA2, 0x82 }; 80861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(truncated, sizeof(truncated)); 81861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_FALSE(ctx.asn1_constructed_skip_all()); 82861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 83861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 84861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, ConstructedSkipAll_Success) { 85861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t data[] = { 0xA0, 0x03, 0x02, 0x01, 0x01, 0xA1, 0x03, 0x02, 0x01, 0x01, 0x06, 0x01, 0xA5 }; 86861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(data, sizeof(data)); 87861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_TRUE(ctx.asn1_constructed_skip_all()); 88861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao const uint8_t* oid; 89861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao size_t length; 90861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_TRUE(ctx.asn1_oid_get(&oid, &length)); 91861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(1U, length); 92861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(0xA5U, *oid); 93861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 94861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 95861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, SequenceGet_TruncatedLength_Failure) { 96861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t truncated[] = { 0x30, 0x82 }; 97861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(truncated, sizeof(truncated)); 98861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(nullptr, ctx.asn1_sequence_get()); 99861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 100861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 101861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, SequenceGet_TooSmallForChild_Failure) { 102861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t data[] = { 0x30, 0x02, 0x06, 0x01, 0x01 }; 103861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(data, sizeof(data)); 104861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao std::unique_ptr<asn1_context> ptr(ctx.asn1_sequence_get()); 105861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_NE(nullptr, ptr); 106861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao const uint8_t* oid; 107861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao size_t length; 108861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_FALSE(ptr->asn1_oid_get(&oid, &length)); 109861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 110861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 111861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, SequenceGet_Success) { 112861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t data[] = { 0x30, 0x03, 0x06, 0x01, 0x01 }; 113861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(data, sizeof(data)); 114861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao std::unique_ptr<asn1_context> ptr(ctx.asn1_sequence_get()); 115861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_NE(nullptr, ptr); 116861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao const uint8_t* oid; 117861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao size_t length; 118861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_TRUE(ptr->asn1_oid_get(&oid, &length)); 119861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(1U, length); 120861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(0x01U, *oid); 121861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 122861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 123861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, SetGet_TruncatedLength_Failure) { 124861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t truncated[] = { 0x31, 0x82 }; 125861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(truncated, sizeof(truncated)); 126861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(nullptr, ctx.asn1_set_get()); 127861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 128861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 129861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, SetGet_TooSmallForChild_Failure) { 130861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t data[] = { 0x31, 0x02, 0x06, 0x01, 0x01 }; 131861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(data, sizeof(data)); 132861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao std::unique_ptr<asn1_context> ptr(ctx.asn1_set_get()); 133861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_NE(nullptr, ptr); 134861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao const uint8_t* oid; 135861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao size_t length; 136861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_FALSE(ptr->asn1_oid_get(&oid, &length)); 137861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 138861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 139861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, SetGet_Success) { 140861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t data[] = { 0x31, 0x03, 0x06, 0x01, 0xBA }; 141861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(data, sizeof(data)); 142861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao std::unique_ptr<asn1_context> ptr(ctx.asn1_set_get()); 143861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_NE(nullptr, ptr); 144861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao const uint8_t* oid; 145861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao size_t length; 146861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_TRUE(ptr->asn1_oid_get(&oid, &length)); 147861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(1U, length); 148861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(0xBAU, *oid); 149861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 150861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 151861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, OidGet_LengthZero_Failure) { 152861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t data[] = { 0x06, 0x00, 0x01 }; 153861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(data, sizeof(data)); 154861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao const uint8_t* oid; 155861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao size_t length; 156861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_FALSE(ctx.asn1_oid_get(&oid, &length)); 157861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 158861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 159861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, OidGet_TooSmall_Failure) { 160861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t data[] = { 0x06, 0x01 }; 161861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(data, sizeof(data)); 162861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao const uint8_t* oid; 163861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao size_t length; 164861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_FALSE(ctx.asn1_oid_get(&oid, &length)); 165861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 166861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 167861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, OidGet_Success) { 168861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t data[] = { 0x06, 0x01, 0x99 }; 169861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(data, sizeof(data)); 170861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao const uint8_t* oid; 171861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao size_t length; 172861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_TRUE(ctx.asn1_oid_get(&oid, &length)); 173861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(1U, length); 174861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(0x99U, *oid); 175861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 176861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 177861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, OctetStringGet_LengthZero_Failure) { 178861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t data[] = { 0x04, 0x00, 0x55 }; 179861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(data, sizeof(data)); 180861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao const uint8_t* string; 181861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao size_t length; 182861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_FALSE(ctx.asn1_octet_string_get(&string, &length)); 183861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 184861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 185861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, OctetStringGet_TooSmall_Failure) { 186861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t data[] = { 0x04, 0x01 }; 187861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(data, sizeof(data)); 188861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao const uint8_t* string; 189861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao size_t length; 190861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_FALSE(ctx.asn1_octet_string_get(&string, &length)); 191861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 192861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao 193861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao BaoTEST(Asn1DecoderTest, OctetStringGet_Success) { 194861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao uint8_t data[] = { 0x04, 0x01, 0xAA }; 195861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao asn1_context ctx(data, sizeof(data)); 196861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao const uint8_t* string; 197861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao size_t length; 198861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_TRUE(ctx.asn1_octet_string_get(&string, &length)); 199861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(1U, length); 200861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao ASSERT_EQ(0xAAU, *string); 201861c53c6c55db4cf6cb76d35f92804cabf1cd444Tao Bao} 202