1+ // MatterDotNet Copyright (C) 2024
2+ //
3+ // This program is free software: you can redistribute it and/or modify
4+ // it under the terms of the GNU Affero General Public License as published by
5+ // the Free Software Foundation, either version 3 of the License, or any later version.
6+ // This program is distributed in the hope that it will be useful,
7+ // but WITHOUT ANY WARRANTY, without even the implied warranty of
8+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9+ // See the GNU Affero General Public License for more details.
10+ // You should have received a copy of the GNU Affero General Public License
11+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
12+ //
13+ // WARNING: This file was auto-generated. Do not edit.
14+
15+ using MatterDotNet . Protocol . Parsers ;
16+ using MatterDotNet . Protocol . Payloads ;
17+ using System . Diagnostics . CodeAnalysis ;
18+
19+ namespace MatterDotNet . Messages . Certificates
20+ {
21+ public record Extension : TLVPayload
22+ {
23+ /// <inheritdoc />
24+ public Extension ( ) { }
25+
26+ /// <inheritdoc />
27+ [ SetsRequiredMembers ]
28+ public Extension ( Memory < byte > data ) : this ( new TLVReader ( data ) ) { }
29+
30+ public BasicConstraints ? BasicCnstr { get ; set ; }
31+ public ushort ? KeyUsage { get ; set ; }
32+ public uint [ ] ? ExtendedKeyUsage { get ; set ; }
33+ public byte [ ] ? SubjectKeyId { get ; set ; }
34+ public byte [ ] ? AuthorityKeyId { get ; set ; }
35+ public byte [ ] ? FutureExtension { get ; set ; }
36+
37+ /// <inheritdoc />
38+ [ SetsRequiredMembers ]
39+ public Extension ( TLVReader reader , long structNumber = - 1 ) {
40+ if ( reader . IsTag ( 1 ) )
41+ BasicCnstr = new BasicConstraints ( reader , 1 ) ;
42+ else if ( reader . IsTag ( 2 ) )
43+ KeyUsage = reader . GetUShort ( 2 ) ;
44+ else if ( reader . IsTag ( 3 ) )
45+ {
46+ reader . StartArray ( 3 ) ;
47+ List < uint > items = new ( ) ;
48+ while ( ! reader . IsEndContainer ( ) ) {
49+ items . Add ( reader . GetUInt ( - 1 ) ! . Value ) ;
50+ }
51+ reader . EndContainer ( ) ;
52+ ExtendedKeyUsage = items . ToArray ( ) ;
53+ }
54+ else if ( reader . IsTag ( 4 ) )
55+ SubjectKeyId = reader . GetBytes ( 4 ) ;
56+ else if ( reader . IsTag ( 5 ) )
57+ AuthorityKeyId = reader . GetBytes ( 5 ) ;
58+ else if ( reader . IsTag ( 6 ) )
59+ FutureExtension = reader . GetBytes ( 6 ) ;
60+ }
61+
62+ /// <inheritdoc />
63+ public override void Serialize ( TLVWriter writer , long structNumber = - 1 ) {
64+ if ( BasicCnstr != null )
65+ BasicCnstr . Serialize ( writer , 1 ) ;
66+ else if ( KeyUsage != null )
67+ writer . WriteUShort ( 2 , KeyUsage ) ;
68+ else if ( ExtendedKeyUsage != null )
69+ {
70+ writer . StartArray ( 3 ) ;
71+ foreach ( var item in ExtendedKeyUsage ) {
72+ writer . WriteUInt ( - 1 , item ) ;
73+ }
74+ writer . EndContainer ( ) ;
75+ }
76+ else if ( SubjectKeyId != null )
77+ writer . WriteBytes ( 4 , SubjectKeyId ) ;
78+ else if ( AuthorityKeyId != null )
79+ writer . WriteBytes ( 5 , AuthorityKeyId ) ;
80+ else if ( FutureExtension != null )
81+ writer . WriteBytes ( 6 , FutureExtension ) ;
82+ }
83+ }
84+ }
0 commit comments