MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / GetName

Method GetName

extra/yassl/taocrypt/src/asn.cpp:749–861  ·  view source on GitHub ↗

process NAME, either issuer or subject

Source from the content-addressed store, hash-verified

747
748// process NAME, either issuer or subject
749void CertDecoder::GetName(NameType nt)
750{
751 if (source_.GetError().What()) return;
752
753 SHA sha;
754 word32 length = GetSequence(); // length of all distinguished names
755
756 if (length >= ASN_NAME_MAX)
757 return;
758 if (source_.IsLeft(length) == false) return;
759 length += source_.get_index();
760
761 char* ptr;
762 char* buf_end;
763
764 if (nt == ISSUER) {
765 ptr = issuer_;
766 buf_end = ptr + sizeof(issuer_) - 1; // 1 byte for trailing 0
767 }
768 else {
769 ptr = subject_;
770 buf_end = ptr + sizeof(subject_) - 1; // 1 byte for trailing 0
771 }
772
773 while (source_.get_index() < length) {
774 GetSet();
775 if (source_.GetError().What() == SET_E) {
776 source_.SetError(NO_ERROR_E); // extensions may only have sequence
777 source_.prev();
778 }
779 GetSequence();
780
781 byte b = source_.next();
782 if (b != OBJECT_IDENTIFIER) {
783 source_.SetError(OBJECT_ID_E);
784 return;
785 }
786
787 word32 oidSz = GetLength(source_);
788 if (source_.IsLeft(oidSz) == false) return;
789
790 byte joint[2];
791 if (source_.IsLeft(sizeof(joint)) == false) return;
792 memcpy(joint, source_.get_current(), sizeof(joint));
793
794 // v1 name types
795 if (joint[0] == 0x55 && joint[1] == 0x04) {
796 source_.advance(2);
797 byte id = source_.next();
798 b = source_.next(); // strType
799 word32 strLen = GetLength(source_);
800
801 if (source_.IsLeft(strLen) == false) return;
802
803 switch (id) {
804 case COMMON_NAME:
805 if (!(ptr = AddTag(ptr, buf_end, "/CN=", 4, strLen)))
806 return;

Callers

nothing calls this directly

Calls 12

GetLengthFunction · 0.85
IsLeftMethod · 0.80
get_indexMethod · 0.80
advanceMethod · 0.80
WhatMethod · 0.45
GetErrorMethod · 0.45
SetErrorMethod · 0.45
prevMethod · 0.45
nextMethod · 0.45
get_currentMethod · 0.45
UpdateMethod · 0.45
FinalMethod · 0.45

Tested by

no test coverage detected