process NAME, either issuer or subject
| 747 | |
| 748 | // process NAME, either issuer or subject |
| 749 | void 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; |
nothing calls this directly
no test coverage detected