-
Notifications
You must be signed in to change notification settings - Fork 2
/
csra.go
1064 lines (1038 loc) · 40.8 KB
/
csra.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// The csra package implements the CSRA client protocol.
//
// # Introduction
//
// The Certificate Services Remote Administration Protocol consists of a set of Distributed
// Component Object Model (DCOM) interfaces, as specified in [MS-DCOM], that allow administrative
// tools to configure the state and policy of a certification authority (CA) on a server.
//
// For a complete understanding of this protocol, familiarity with public key infrastructure
// (PKI) concepts such as asymmetric and symmetric cryptography, asymmetric and symmetric
// encryption techniques, digital certificate concepts, and cryptographic key establishment
// is required. A comprehensive understanding of the X.509 standard, as specified in
// [X509], is also required.
//
// The Handbook of Applied Cryptography provides an excellent introduction to cryptography
// and PKI concepts. For more information, see [CRYPTO]. The X.509 standard, as specified
// in [X509], provides an excellent introduction to PKI and certificate concepts. Certificate
// revocation and status checking provides an excellent introduction to certificate
// revocation lists (CRLs) and revocation concepts. For more information, see [MSFT-CRL].
//
// # Overview
//
// The Certificate Services Remote Administration Protocol consists of a set of DCOM
// interfaces, as specified in [MS-DCOM], that allow administrative tools to configure
// the state and policy of a CA on a server. The administrative tools can perform such
// functions as getting or setting properties on a CA, retrieving data, revoking certificates,
// or retrieving escrowed private keys from a CA.
//
// The following figure reflects only CA administration, not the normal operation of
// the CA. The protocol for the normal operation of the Microsoft CA is specified in
// [MS-WCCE].
package csra
import (
"context"
"fmt"
"strings"
"unicode/utf16"
dcerpc "github.com/oiweiwei/go-msrpc/dcerpc"
errors "github.com/oiweiwei/go-msrpc/dcerpc/errors"
uuid "github.com/oiweiwei/go-msrpc/midl/uuid"
dcom "github.com/oiweiwei/go-msrpc/msrpc/dcom"
ndr "github.com/oiweiwei/go-msrpc/ndr"
)
var (
_ = context.Background
_ = fmt.Errorf
_ = utf16.Encode
_ = strings.TrimPrefix
_ = ndr.ZeroString
_ = (*uuid.UUID)(nil)
_ = (*dcerpc.SyntaxID)(nil)
_ = (*errors.Error)(nil)
_ = dcom.GoPackage
)
var (
// import guard
GoPackage = "dcom/csra"
)
// CertTransportBlob structure represents CERTTRANSBLOB RPC structure.
//
// The CERTTRANSBLOB structure defines a byte buffer that is used to store and request
// certificates, transmit responses, manipulate Unicode strings, and marshal property
// values.
type CertTransportBlob struct {
// cb: An unsigned integer value that MUST contain the length, in bytes, of the buffer
// that is pointed to by pb.
Length uint32 `idl:"name:cb" json:"length"`
// pb: The BYTE buffer that contains the binary contents being transported in this
// CERTTRANSBLOB. That content consists of any of the following entities:
//
// * A certificate.
//
// * A certificate request.
//
// * CA ( c6451297-197d-4b4b-b786-3f3187b67b8f#gt_c925d5d7-a442-4ba4-9586-5f94ccec847a
// ) properties.
//
// * Any common structure that is defined in section 2.2.1 ( d9e0f247-2b38-466d-934b-83093c6a11a5
// ) other than VARIANT ( 8d5e0fb0-f357-48b2-808c-bb125fd0609e ) or CERTVIEWRESTRICTION
// ( 5503c7fa-c78e-4fda-adc9-21030751bce7 ).
//
// * Any common structure that is defined in [MS-WCCE] ( ../ms-wcce/446a0fca-7f27-4436-965d-191635518466
// ) section 2.2.2 ( ../ms-wcce/a2d33e71-31d9-4934-a369-07ed8c502ae5 ).
//
// The CERTTRANSBLOB structure is empty when cb is set to 0 and pb is set to NULL.
//
// The marshaling of other structures that can be passed in the pb byte buffer of CERTTRANSBLOB
// is defined in [MS-WCCE] section 2.2.2.
//
// All instances of CERTTRANSBLOB that are used by this protocol MUST use the marshaling
// rules that are described in the following sections or in [MS-WCCE] section 2.2.2.
Buffer []byte `idl:"name:pb;size_is:(cb);pointer:unique" json:"buffer"`
}
func (o *CertTransportBlob) xxx_PreparePayload(ctx context.Context) error {
if o.Buffer != nil && o.Length == 0 {
o.Length = uint32(len(o.Buffer))
}
if hook, ok := (interface{})(o).(interface{ AfterPreparePayload(context.Context) error }); ok {
if err := hook.AfterPreparePayload(ctx); err != nil {
return err
}
}
return nil
}
func (o *CertTransportBlob) MarshalNDR(ctx context.Context, w ndr.Writer) error {
if err := o.xxx_PreparePayload(ctx); err != nil {
return err
}
if err := w.WriteAlign(9); err != nil {
return err
}
if err := w.WriteData(o.Length); err != nil {
return err
}
if o.Buffer != nil || o.Length > 0 {
_ptr_pb := ndr.MarshalNDRFunc(func(ctx context.Context, w ndr.Writer) error {
dimSize1 := uint64(o.Length)
if err := w.WriteSize(dimSize1); err != nil {
return err
}
sizeInfo := []uint64{
dimSize1,
}
for i1 := range o.Buffer {
i1 := i1
if uint64(i1) >= sizeInfo[0] {
break
}
if err := w.WriteData(o.Buffer[i1]); err != nil {
return err
}
}
for i1 := len(o.Buffer); uint64(i1) < sizeInfo[0]; i1++ {
if err := w.WriteData(uint8(0)); err != nil {
return err
}
}
return nil
})
if err := w.WritePointer(&o.Buffer, _ptr_pb); err != nil {
return err
}
} else {
if err := w.WritePointer(nil); err != nil {
return err
}
}
return nil
}
func (o *CertTransportBlob) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
if err := w.ReadAlign(9); err != nil {
return err
}
if err := w.ReadData(&o.Length); err != nil {
return err
}
_ptr_pb := ndr.UnmarshalNDRFunc(func(ctx context.Context, w ndr.Reader) error {
sizeInfo := []uint64{
0,
}
for sz1 := range sizeInfo {
if err := w.ReadSize(&sizeInfo[sz1]); err != nil {
return err
}
}
// XXX: for opaque unmarshaling
if o.Length > 0 && sizeInfo[0] == 0 {
sizeInfo[0] = uint64(o.Length)
}
if sizeInfo[0] > uint64(w.Len()) /* sanity-check */ {
return fmt.Errorf("buffer overflow for size %d of array o.Buffer", sizeInfo[0])
}
o.Buffer = make([]byte, sizeInfo[0])
for i1 := range o.Buffer {
i1 := i1
if err := w.ReadData(&o.Buffer[i1]); err != nil {
return err
}
}
return nil
})
_s_pb := func(ptr interface{}) { o.Buffer = *ptr.(*[]byte) }
if err := w.ReadPointer(&o.Buffer, _s_pb, _ptr_pb); err != nil {
return err
}
return nil
}
// CATransportProperty structure represents CATRANSPROP RPC structure.
//
// The CATRANSPROP structure encapsulates information about a CA property. The CATRANSPROP
// structure and the marshaling of one or more CATRANSPROP structures into a CERTTRANSBLOB
// structure is specified in [MS-WCCE] section 2.2.2.3.
type CATransportProperty struct {
PropertyID int32 `idl:"name:lPropID" json:"property_id"`
PropertyType uint8 `idl:"name:propType" json:"property_type"`
_ uint8 `idl:"name:Reserved"`
PropertyFlags uint16 `idl:"name:propFlags" json:"property_flags"`
DisplayNameOffset uint32 `idl:"name:obwszDisplayName" json:"display_name_offset"`
}
func (o *CATransportProperty) xxx_PreparePayload(ctx context.Context) error {
if hook, ok := (interface{})(o).(interface{ AfterPreparePayload(context.Context) error }); ok {
if err := hook.AfterPreparePayload(ctx); err != nil {
return err
}
}
return nil
}
func (o *CATransportProperty) MarshalNDR(ctx context.Context, w ndr.Writer) error {
if err := o.xxx_PreparePayload(ctx); err != nil {
return err
}
if err := w.WriteAlign(4); err != nil {
return err
}
if err := w.WriteData(o.PropertyID); err != nil {
return err
}
if err := w.WriteData(o.PropertyType); err != nil {
return err
}
// reserved Reserved
if err := w.WriteData(uint8(0)); err != nil {
return err
}
if err := w.WriteData(o.PropertyFlags); err != nil {
return err
}
if err := w.WriteData(o.DisplayNameOffset); err != nil {
return err
}
return nil
}
func (o *CATransportProperty) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
if err := w.ReadAlign(4); err != nil {
return err
}
if err := w.ReadData(&o.PropertyID); err != nil {
return err
}
if err := w.ReadData(&o.PropertyType); err != nil {
return err
}
// reserved Reserved
var _Reserved uint8
if err := w.ReadData(&_Reserved); err != nil {
return err
}
if err := w.ReadData(&o.PropertyFlags); err != nil {
return err
}
if err := w.ReadData(&o.DisplayNameOffset); err != nil {
return err
}
return nil
}
// CertTransDBAttribute structure represents CERTTRANSDBATTRIBUTE RPC structure.
//
// The CERTTRANSDBATTRIBUTE structure is encoded within a CERTTRANSBLOB structure. The
// CERTTRANSDBATTRIBUTE structure is used by the server to return attribute information
// that is associated with a request to the client (upon the client's query via invocation
// of the EnumAttributesOrExtensions method of the ICertAdminD interface).
type CertTransDBAttribute struct {
// obwszName: An integer that contains the offset from the beginning of the byte array
// buffer that is pointed to by the pb member in the containing CERTTRANSBLOB structure
// to where the string that contains the name of this attribute can be found. The format
// is a null-terminated UNICODE string. The offset MUST be divisible by 4.
NameOffset uint32 `idl:"name:obwszName" json:"name_offset"`
// obwszValue: An integer that contains the offset from the beginning of the byte array
// buffer that is pointed to by the pb member in the containing CERTTRANSBLOB structure
// to where the string that contains the value of this attribute can be found. The format
// is a null-terminated UNICODE string. The offset MUST be divisible by 4.
ValueOffset uint32 `idl:"name:obwszValue" json:"value_offset"`
}
func (o *CertTransDBAttribute) xxx_PreparePayload(ctx context.Context) error {
if hook, ok := (interface{})(o).(interface{ AfterPreparePayload(context.Context) error }); ok {
if err := hook.AfterPreparePayload(ctx); err != nil {
return err
}
}
return nil
}
func (o *CertTransDBAttribute) MarshalNDR(ctx context.Context, w ndr.Writer) error {
if err := o.xxx_PreparePayload(ctx); err != nil {
return err
}
if err := w.WriteAlign(4); err != nil {
return err
}
if err := w.WriteData(o.NameOffset); err != nil {
return err
}
if err := w.WriteData(o.ValueOffset); err != nil {
return err
}
return nil
}
func (o *CertTransDBAttribute) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
if err := w.ReadAlign(4); err != nil {
return err
}
if err := w.ReadData(&o.NameOffset); err != nil {
return err
}
if err := w.ReadData(&o.ValueOffset); err != nil {
return err
}
return nil
}
// CertTransDBExtension structure represents CERTTRANSDBEXTENSION RPC structure.
//
// The CERTTRANSDBEXTENSION structure is encoded within a CERTTRANSBLOB structure. The
// CERTTRANSDBEXTENSION structure is used by the server to return certificate extension
// information, as specified in [RFC3280] section 4, that is associated with a request.
// This associated request to the client occurs when the client performs a query by
// invoking the EnumAttributesOrExtensions method of the ICertAdminD interface.
type CertTransDBExtension struct {
// obwszName: An unsigned integer that contains the offset from the beginning of the
// byte array buffer that is pointed to by the pb member in the containing CERTTRANSBLOB
// structure to the string representation of an OID (1) of this extension (as specified
// in [X680]). The string format is a null-terminated UNICODE string. The offset MUST
// be divisible by 4.
NameOffset uint32 `idl:"name:obwszName" json:"name_offset"`
// ExtFlags: An integer value that specifies the flags that are associated with the
// extension. The following diagram shows its contents.
//
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
// | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 2 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 3 | 1 |
// | | | | | | | | | | | 0 | | | | | | | | | | 0 | | | | | | | | | | 0 | |
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
// | Nigiro |
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
//
// C (1 bit): C is the ExtensionCriticalFlag, as defined in section 3.1.1.3, the Extension_Flags
// ADM element. A value of 0 means the extension is not critical. A value of 1 means
// the extension is critical.
//
// D (1 bit): D is the ExtensionDisabledFlag, as defined in section 3.1.1.3, the Extension_Flags
// ADM element. A value of 0 means the extension is not disabled. A value of 1 means
// the extension is disabled.
//
// Nigiro (2 bytes): The Nigiro field is defined as follows:
//
// +------------------------+----------------------------------------------------------------------------------+
// | MIRRORED (NIGIRO) | |
// | BYTE | MEANING |
// | | |
// +------------------------+----------------------------------------------------------------------------------+
// +------------------------+----------------------------------------------------------------------------------+
// | 0x8000 | The extension comes from the request. |
// +------------------------+----------------------------------------------------------------------------------+
// | 0x4000 | The extension was added by the CA. The CA assigns a value of 2 if the extension |
// | | was added by the policy module of the CA. |
// +------------------------+----------------------------------------------------------------------------------+
// | 0xC000 | The extension was added by the CA. The CA assigns a value of 3 if the extension |
// | | was added interactively by a human administrator of the CA. |
// +------------------------+----------------------------------------------------------------------------------+
// | 0x2000 | The extension was added by the CA. The CA assigns a value of 4 if the extension |
// | | was added by the certificate server engine and not the policy module component |
// | | of the CA. |
// +------------------------+----------------------------------------------------------------------------------+
// | 0xA000 | The extension was in the preceding certificate, which might occur, for example, |
// | | when a certificate is renewed. |
// +------------------------+----------------------------------------------------------------------------------+
// | 0x6000 | The extension comes from an imported certificate (a certificate that was |
// | | imported into the CA database). |
// +------------------------+----------------------------------------------------------------------------------+
// | 0xE000 | The extension comes from a PKCS7 request. |
// +------------------------+----------------------------------------------------------------------------------+
// | 0x1000 | The extension comes from a CMC request. |
// +------------------------+----------------------------------------------------------------------------------+
// | 0x9000 | The extension comes from the current CA signing certificate. |
// +------------------------+----------------------------------------------------------------------------------+
ExtFlags int32 `idl:"name:ExtFlags" json:"ext_flags"`
// cbValue: An unsigned integer value that contains the length, in bytes, of data that
// is referenced by the obValue parameter.
ValueLength uint32 `idl:"name:cbValue" json:"value_length"`
// obValue: An unsigned integer that contains the offset from the beginning of the
// byte array buffer that is pointed to by the pb member in the containing CERTTRANSBLOB
// structure to where the value for this extension can be found. The length of the value
// is specified in the cbValue field. The value is in ASN.1 Distinguished Encoding Rules
// (DER) format for the extension, as specified in [X660]. The offset MUST be divisible
// by 4.
ValueOffset uint32 `idl:"name:obValue" json:"value_offset"`
}
func (o *CertTransDBExtension) xxx_PreparePayload(ctx context.Context) error {
if hook, ok := (interface{})(o).(interface{ AfterPreparePayload(context.Context) error }); ok {
if err := hook.AfterPreparePayload(ctx); err != nil {
return err
}
}
return nil
}
func (o *CertTransDBExtension) MarshalNDR(ctx context.Context, w ndr.Writer) error {
if err := o.xxx_PreparePayload(ctx); err != nil {
return err
}
if err := w.WriteAlign(4); err != nil {
return err
}
if err := w.WriteData(o.NameOffset); err != nil {
return err
}
if err := w.WriteData(o.ExtFlags); err != nil {
return err
}
if err := w.WriteData(o.ValueLength); err != nil {
return err
}
if err := w.WriteData(o.ValueOffset); err != nil {
return err
}
return nil
}
func (o *CertTransDBExtension) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
if err := w.ReadAlign(4); err != nil {
return err
}
if err := w.ReadData(&o.NameOffset); err != nil {
return err
}
if err := w.ReadData(&o.ExtFlags); err != nil {
return err
}
if err := w.ReadData(&o.ValueLength); err != nil {
return err
}
if err := w.ReadData(&o.ValueOffset); err != nil {
return err
}
return nil
}
// CertTransDBColumn structure represents CERTTRANSDBCOLUMN RPC structure.
//
// The CERTTRANSDBCOLUMN structure is encoded within a CERTTRANSBLOB structure. The
// CERTTRANSDBCOLUMN structure contains schema information about a particular database
// column that is associated with a specific table to the client. This associated table
// is invoked when the client queries the EnumViewColumn or EnumViewColumnTable method
// of the ICertAdminD and ICertAdminD2 interfaces, respectively.
//
// The CERTTRANSDBCOLUMN structure (section 2.2.1.7) is encoded within the byte array
// that is referenced by the pb member of a CERTTRANSBLOB structure (section 2.2.1.4).
//
// The packet that contains an array of some number, "N", of CERTTRANSDBCOLUMN structures
// is specified in the following packet diagrams. The actual value of "N" is a separate
// return parameter for the EnumViewColumn (section 3.1.4.1.9) and EnumViewColumnTable
// (section 3.2.4.2.5) methods.
//
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
// | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 2 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 3 | 1 |
// | | | | | | | | | | | 0 | | | | | | | | | | 0 | | | | | | | | | | 0 | |
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
// | CERTTRANSDBCOLUMN Structures (variable) |
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
// | ... |
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
// | ... |
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
// | Column_Schema_Data (variable) |
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
// | ... |
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
// | ... |
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
type CertTransDBColumn struct {
// Type: This field describes the column. It consists of two WORDs, a high WORD and
// a low WORD, which are used separately.
//
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
// | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 2 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 3 | 1 |
// | | | | | | | | | | | 0 | | | | | | | | | | 0 | | | | | | | | | | 0 | |
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
// | Column Flags | Column Type |
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
Type uint32 `idl:"name:Type" json:"type"`
// Index: An unsigned integer value that specifies the identifier for the column in
// the server database.
Index uint32 `idl:"name:Index" json:"index"`
// cbMax: An unsigned integer value that specifies the maximum data size, in bytes,
// that this column can contain.
MaxLength uint32 `idl:"name:cbMax" json:"max_length"`
// obwszName: An integer that contains the offset from the beginning of the byte array
// buffer that is pointed to by the pb member in the containing CERTTRANSBLOB structure,
// to where the string that contains the name of this column can be found. The string
// format is a null-terminated UNICODE string. The offset MUST be divisible by 4.
NameOffset uint32 `idl:"name:obwszName" json:"name_offset"`
// obwszDisplayName: An integer that contains the offset from the beginning of the
// byte array buffer that is pointed to by the pb member in the containing CERTTRANSBLOB
// structure, to where the string that contains the display name of this column can
// be found. The string format is a null-terminated UNICODE string. The offset MUST
// be divisible by 4.
DisplayNameOffset uint32 `idl:"name:obwszDisplayName" json:"display_name_offset"`
}
func (o *CertTransDBColumn) xxx_PreparePayload(ctx context.Context) error {
if hook, ok := (interface{})(o).(interface{ AfterPreparePayload(context.Context) error }); ok {
if err := hook.AfterPreparePayload(ctx); err != nil {
return err
}
}
return nil
}
func (o *CertTransDBColumn) MarshalNDR(ctx context.Context, w ndr.Writer) error {
if err := o.xxx_PreparePayload(ctx); err != nil {
return err
}
if err := w.WriteAlign(4); err != nil {
return err
}
if err := w.WriteData(o.Type); err != nil {
return err
}
if err := w.WriteData(o.Index); err != nil {
return err
}
if err := w.WriteData(o.MaxLength); err != nil {
return err
}
if err := w.WriteData(o.NameOffset); err != nil {
return err
}
if err := w.WriteData(o.DisplayNameOffset); err != nil {
return err
}
return nil
}
func (o *CertTransDBColumn) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
if err := w.ReadAlign(4); err != nil {
return err
}
if err := w.ReadData(&o.Type); err != nil {
return err
}
if err := w.ReadData(&o.Index); err != nil {
return err
}
if err := w.ReadData(&o.MaxLength); err != nil {
return err
}
if err := w.ReadData(&o.NameOffset); err != nil {
return err
}
if err := w.ReadData(&o.DisplayNameOffset); err != nil {
return err
}
return nil
}
// CertTransDBResultColumn structure represents CERTTRANSDBRESULTCOLUMN RPC structure.
//
// The CERTTRANSDBRESULTCOLUMN structure is encoded within a CERTTRANSBLOB structure.
// The CERTTRANSDBRESULTCOLUMN structure is used by the server to return the result
// of a CA database query that is done by the client (upon the client's query via invocation
// of the OpenView or EnumView method of the ICertAdminD interface).
//
// The OpenView and EnumView methods return data in the form of a CERTTRANSBLOB structure
// whose pb member points to an array of one or more CERTTRANSDBRESULTROW structures.
// Each CERTTRANSDBRESULTROW structure contains one or more CERTTRANSDBRESULTCOLUMN
// structures.
//
// The CERTTRANSDBRESULTCOLUMN structure contains data for a specific column in a specific
// row.
type CertTransDBResultColumn struct {
// Type: This field describes the column. It consists of two WORDs, a high WORD and
// a low WORD, which are used separately.
//
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
// | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 2 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 3 | 1 |
// | | | | | | | | | | | 0 | | | | | | | | | | 0 | | | | | | | | | | 0 | |
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
// | Column Flags | Column Type |
// +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
Type uint32 `idl:"name:Type" json:"type"`
// Index: An unsigned integer value that specifies the identifier for the column in
// the relevant table.
Index uint32 `idl:"name:Index" json:"index"`
// obValue: An unsigned integer that contains the offset from the beginning of the
// corresponding CERTTRANSDBRESULTROW structure to where the value for this column can
// be found. The length of the value is specified in the cbValue field. The offset MUST
// be DWORD aligned.
ValueOffset uint32 `idl:"name:obValue" json:"value_offset"`
// cbValue: An unsigned integer value that specifies the length, in bytes, of the value
// for the specific column.
ValueLength uint32 `idl:"name:cbValue" json:"value_length"`
}
func (o *CertTransDBResultColumn) xxx_PreparePayload(ctx context.Context) error {
if hook, ok := (interface{})(o).(interface{ AfterPreparePayload(context.Context) error }); ok {
if err := hook.AfterPreparePayload(ctx); err != nil {
return err
}
}
return nil
}
func (o *CertTransDBResultColumn) MarshalNDR(ctx context.Context, w ndr.Writer) error {
if err := o.xxx_PreparePayload(ctx); err != nil {
return err
}
if err := w.WriteAlign(4); err != nil {
return err
}
if err := w.WriteData(o.Type); err != nil {
return err
}
if err := w.WriteData(o.Index); err != nil {
return err
}
if err := w.WriteData(o.ValueOffset); err != nil {
return err
}
if err := w.WriteData(o.ValueLength); err != nil {
return err
}
return nil
}
func (o *CertTransDBResultColumn) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
if err := w.ReadAlign(4); err != nil {
return err
}
if err := w.ReadData(&o.Type); err != nil {
return err
}
if err := w.ReadData(&o.Index); err != nil {
return err
}
if err := w.ReadData(&o.ValueOffset); err != nil {
return err
}
if err := w.ReadData(&o.ValueLength); err != nil {
return err
}
return nil
}
// CertTransDBResultRow structure represents CERTTRANSDBRESULTROW RPC structure.
//
// The CERTTRANSDBRESULTROW structure is encoded within a CERTTRANSBLOB structure. The
// CERTTRANSDBRESULTROW structure is used by the server to return the result of the
// database query done by the client (upon the client's query via invocation of OpenView
// or EnumView methods of the ICertAdminD interface). This structure contains data for
// a specific row.
type CertTransDBResultRow struct {
// rowid: Unsigned integer value that specifies the identifier for the row.
RowID uint32 `idl:"name:rowid" json:"row_id"`
// ccol: Unsigned integer value that specifies the count of CERTTRANSDBRESULTCOLUMN
// structures. Each structure contains the value of a specific column in the row identified
// by rowid.
ColumnsCount uint32 `idl:"name:ccol" json:"columns_count"`
// cbrow: Unsigned integer value that specifies the total size of row data (in bytes).
// This is the sum of the size of CERTTRANSDBRESULTROW structure, size of each CERTTRANSDBRESULTCOLUMN
// structure for the row (the count of which is specified by ccol), and the DWORD-rounded-up
// size of each column value.
RowLength uint32 `idl:"name:cbrow" json:"row_length"`
}
func (o *CertTransDBResultRow) xxx_PreparePayload(ctx context.Context) error {
if hook, ok := (interface{})(o).(interface{ AfterPreparePayload(context.Context) error }); ok {
if err := hook.AfterPreparePayload(ctx); err != nil {
return err
}
}
return nil
}
func (o *CertTransDBResultRow) MarshalNDR(ctx context.Context, w ndr.Writer) error {
if err := o.xxx_PreparePayload(ctx); err != nil {
return err
}
if err := w.WriteAlign(4); err != nil {
return err
}
if err := w.WriteData(o.RowID); err != nil {
return err
}
if err := w.WriteData(o.ColumnsCount); err != nil {
return err
}
if err := w.WriteData(o.RowLength); err != nil {
return err
}
return nil
}
func (o *CertTransDBResultRow) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
if err := w.ReadAlign(4); err != nil {
return err
}
if err := w.ReadData(&o.RowID); err != nil {
return err
}
if err := w.ReadData(&o.ColumnsCount); err != nil {
return err
}
if err := w.ReadData(&o.RowLength); err != nil {
return err
}
return nil
}
// CertViewRestriction structure represents CERTVIEWRESTRICTION RPC structure.
//
// The CERTVIEWRESTRICTION structure is used to restrict the data set that is returned
// by the CA server during calls to the OpenView method for the ICertAdminD interface.
//
// This structure is passed by RPC technology, as specified in [MS-RPCE], and does not
// need special marshaling.
type CertViewRestriction struct {
// ColumnIndex: An unsigned integer value that specifies the identifier for the database
// column that is receiving the restriction.
ColumnIndex uint32 `idl:"name:ColumnIndex" json:"column_index"`
// SeekOperator: An integer value that specifies the logical operator of the data-query
// qualifier for the column. This parameter MUST be set to one of the following values.
//
// +------------+--------------------------+
// | | |
// | VALUE | MEANING |
// | | |
// +------------+--------------------------+
// +------------+--------------------------+
// | 0x00000001 | Equal to |
// +------------+--------------------------+
// | 0x00000002 | Less than |
// +------------+--------------------------+
// | 0x00000004 | Less than or equal to |
// +------------+--------------------------+
// | 0x00000008 | Greater than or equal to |
// +------------+--------------------------+
// | 0x00000010 | Greater than |
// +------------+--------------------------+
SeekOperator int32 `idl:"name:SeekOperator" json:"seek_operator"`
// SortOrder: An integer value that specifies the sort order for the column. This parameter
// MUST be set to one of the following values.
//
// +------------+---------------+
// | | |
// | VALUE | MEANING |
// | | |
// +------------+---------------+
// +------------+---------------+
// | 0x00000000 | No sort order |
// +------------+---------------+
// | 0x00000001 | Ascending |
// +------------+---------------+
// | 0x00000002 | Descending |
// +------------+---------------+
SortOrder int32 `idl:"name:SortOrder" json:"sort_order"`
// pbValue: A pointer to a byte array that specifies the value against which the value
// in the corresponding column (specified by ColumnIndex) is compared, using SeekOperator.
Value []byte `idl:"name:pbValue;size_is:(cbValue);pointer:unique" json:"value"`
// cbValue: An unsigned integer value that specifies the length of the byte array that
// is pointed to by the pbValue field.
ValueLength uint32 `idl:"name:cbValue" json:"value_length"`
}
func (o *CertViewRestriction) xxx_PreparePayload(ctx context.Context) error {
if o.Value != nil && o.ValueLength == 0 {
o.ValueLength = uint32(len(o.Value))
}
if hook, ok := (interface{})(o).(interface{ AfterPreparePayload(context.Context) error }); ok {
if err := hook.AfterPreparePayload(ctx); err != nil {
return err
}
}
return nil
}
func (o *CertViewRestriction) MarshalNDR(ctx context.Context, w ndr.Writer) error {
if err := o.xxx_PreparePayload(ctx); err != nil {
return err
}
if err := w.WriteAlign(9); err != nil {
return err
}
if err := w.WriteData(o.ColumnIndex); err != nil {
return err
}
if err := w.WriteData(o.SeekOperator); err != nil {
return err
}
if err := w.WriteData(o.SortOrder); err != nil {
return err
}
if o.Value != nil || o.ValueLength > 0 {
_ptr_pbValue := ndr.MarshalNDRFunc(func(ctx context.Context, w ndr.Writer) error {
dimSize1 := uint64(o.ValueLength)
if err := w.WriteSize(dimSize1); err != nil {
return err
}
sizeInfo := []uint64{
dimSize1,
}
for i1 := range o.Value {
i1 := i1
if uint64(i1) >= sizeInfo[0] {
break
}
if err := w.WriteData(o.Value[i1]); err != nil {
return err
}
}
for i1 := len(o.Value); uint64(i1) < sizeInfo[0]; i1++ {
if err := w.WriteData(uint8(0)); err != nil {
return err
}
}
return nil
})
if err := w.WritePointer(&o.Value, _ptr_pbValue); err != nil {
return err
}
} else {
if err := w.WritePointer(nil); err != nil {
return err
}
}
if err := w.WriteData(o.ValueLength); err != nil {
return err
}
return nil
}
func (o *CertViewRestriction) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
if err := w.ReadAlign(9); err != nil {
return err
}
if err := w.ReadData(&o.ColumnIndex); err != nil {
return err
}
if err := w.ReadData(&o.SeekOperator); err != nil {
return err
}
if err := w.ReadData(&o.SortOrder); err != nil {
return err
}
_ptr_pbValue := ndr.UnmarshalNDRFunc(func(ctx context.Context, w ndr.Reader) error {
sizeInfo := []uint64{
0,
}
for sz1 := range sizeInfo {
if err := w.ReadSize(&sizeInfo[sz1]); err != nil {
return err
}
}
// XXX: for opaque unmarshaling
if o.ValueLength > 0 && sizeInfo[0] == 0 {
sizeInfo[0] = uint64(o.ValueLength)
}
if sizeInfo[0] > uint64(w.Len()) /* sanity-check */ {
return fmt.Errorf("buffer overflow for size %d of array o.Value", sizeInfo[0])
}
o.Value = make([]byte, sizeInfo[0])
for i1 := range o.Value {
i1 := i1
if err := w.ReadData(&o.Value[i1]); err != nil {
return err
}
}
return nil
})
_s_pbValue := func(ptr interface{}) { o.Value = *ptr.(*[]byte) }
if err := w.ReadPointer(&o.Value, _s_pbValue, _ptr_pbValue); err != nil {
return err
}
if err := w.ReadData(&o.ValueLength); err != nil {
return err
}
return nil
}
// CertAdminD2 structure represents ICertAdminD2 RPC structure.
type CertAdminD2 dcom.InterfacePointer
func (o *CertAdminD2) InterfacePointer() *dcom.InterfacePointer { return (*dcom.InterfacePointer)(o) }
func (o *CertAdminD2) xxx_PreparePayload(ctx context.Context) error {
if o.Data != nil && o.DataCount == 0 {
o.DataCount = uint32(len(o.Data))
}
if hook, ok := (interface{})(o).(interface{ AfterPreparePayload(context.Context) error }); ok {
if err := hook.AfterPreparePayload(ctx); err != nil {
return err
}
}
return nil
}
func (o *CertAdminD2) NDRSizeInfo() []uint64 {
dimSize1 := uint64(o.DataCount)
return []uint64{
dimSize1,
}
}
func (o *CertAdminD2) MarshalNDR(ctx context.Context, w ndr.Writer) error {
if err := o.xxx_PreparePayload(ctx); err != nil {
return err
}
sizeInfo, ok := ctx.Value(ndr.SizeInfo).([]uint64)
if !ok {
sizeInfo = o.NDRSizeInfo()
for sz1 := range sizeInfo {
if err := w.WriteSize(sizeInfo[sz1]); err != nil {
return err
}
}
ctx = context.WithValue(ctx, ndr.SizeInfo, sizeInfo)
}
if err := w.WriteAlign(4); err != nil {
return err
}
if err := w.WriteData(o.DataCount); err != nil {
return err
}
for i1 := range o.Data {
i1 := i1
if uint64(i1) >= sizeInfo[0] {
break
}
if err := w.WriteData(o.Data[i1]); err != nil {
return err
}
}
for i1 := len(o.Data); uint64(i1) < sizeInfo[0]; i1++ {
if err := w.WriteData(uint8(0)); err != nil {
return err
}
}
return nil
}
func (o *CertAdminD2) UnmarshalNDR(ctx context.Context, w ndr.Reader) error {
sizeInfo, ok := ctx.Value(ndr.SizeInfo).([]uint64)
if !ok {
sizeInfo = o.NDRSizeInfo()
for i1 := range sizeInfo {
if err := w.ReadSize(&sizeInfo[i1]); err != nil {
return err
}
}
ctx = context.WithValue(ctx, ndr.SizeInfo, sizeInfo)
}
if err := w.ReadAlign(4); err != nil {
return err
}
if err := w.ReadData(&o.DataCount); err != nil {
return err
}
// XXX: for opaque unmarshaling
if o.DataCount > 0 && sizeInfo[0] == 0 {
sizeInfo[0] = uint64(o.DataCount)
}
if sizeInfo[0] > uint64(w.Len()) /* sanity-check */ {
return fmt.Errorf("buffer overflow for size %d of array o.Data", sizeInfo[0])
}
o.Data = make([]byte, sizeInfo[0])
for i1 := range o.Data {
i1 := i1
if err := w.ReadData(&o.Data[i1]); err != nil {
return err
}
}
return nil
}
// CertAdminD structure represents ICertAdminD RPC structure.
type CertAdminD dcom.InterfacePointer
func (o *CertAdminD) InterfacePointer() *dcom.InterfacePointer { return (*dcom.InterfacePointer)(o) }
func (o *CertAdminD) xxx_PreparePayload(ctx context.Context) error {
if o.Data != nil && o.DataCount == 0 {
o.DataCount = uint32(len(o.Data))
}
if hook, ok := (interface{})(o).(interface{ AfterPreparePayload(context.Context) error }); ok {
if err := hook.AfterPreparePayload(ctx); err != nil {
return err
}
}
return nil
}
func (o *CertAdminD) NDRSizeInfo() []uint64 {
dimSize1 := uint64(o.DataCount)
return []uint64{
dimSize1,
}
}
func (o *CertAdminD) MarshalNDR(ctx context.Context, w ndr.Writer) error {
if err := o.xxx_PreparePayload(ctx); err != nil {
return err
}
sizeInfo, ok := ctx.Value(ndr.SizeInfo).([]uint64)