-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path0a_语法练习.asn1
686 lines (557 loc) · 19 KB
/
0a_语法练习.asn1
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
MyModule DEFINITIONS AUTOMATIC TAGS ::= BEGIN
EXPORTS ALL;
Uint3 ::= INTEGER (0..7)
Uint8 ::= INTEGER (0..255)
Uint16 ::= INTEGER (0..65535)
Uint32 ::= INTEGER (0..4294967295)
Uint64 ::= INTEGER (0..18446744073709551615)
IValue ::= Uint16
Opaque ::= OCTET STRING
SequenceOfOctetString ::= SEQUENCE (SIZE (0..MAX)) OF OCTET STRING(SIZE (0..MAX))
SequenceOfUint8 ::= SEQUENCE OF Uint8
SequenceOfUint16 ::= SEQUENCE OF Uint16
V2XSecData ::= SEQUENCE {
protocolVersion Uint8(8),
content V2XSecContent
}
V2XSecContent ::= CHOICE {
unsecuredData Opaque,
signedData SignedData,
encryptedData EncryptedData,
signedCertificateRequest Opaque,
...
}
SignedData ::= SEQUENCE {
hashId HashAlgorithm,
tbsData ToBeSignedData,
signer SignerIdentifier,
signature Signature
}
HashAlgorithm ::= ENUMERATED {
sha256,
...,
sha384,
sm3
}
ToBeSignedData ::= SEQUENCE {
payload SignedDataPayload,
headerInfo HeaderInfo
}
SignedDataPayload ::= SEQUENCE {
data V2XSecData OPTIONAL,
extDataHash HashedData OPTIONAL,
...
} (WITH COMPONENTS {..., data PRESENT} |
WITH COMPONENTS {..., extDataHash PRESENT})
HashedData ::= CHOICE {
sha256HashedData OCTET STRING(SIZE(32)),
...
}
HeaderInfo ::= SEQUENCE {
psid Psid,
generationTime Time64 OPTIONAL,
expiryTime Time64 OPTIONAL,
generationLocation ThreeDLocation OPTIONAL,
p2pcdLearningRequest HashedId3 OPTIONAL,
missingCrlIdentifier MissingCrlIdentifier OPTIONAL,
encryptionKey EncryptionKey OPTIONAL,
...,
inlineP2pcdRequest SequenceOfHashedId3 OPTIONAL,
requestedCertificate Certificate OPTIONAL,
pduFunctionalType PduFunctionalType OPTIONAL
}
Psid ::= INTEGER (0..MAX)
Time64 ::= Uint64
ThreeDLocation ::= SEQUENCE {
latitude Latitude,
longitude Longitude,
elevation Elevation
}
Latitude ::= NinetyDegreeInt
NinetyDegreeInt ::= INTEGER {
min (-900000000),
max ( 900000000),
unknown ( 900000001)
} (-900000000..900000001)
KnownLatitude ::= NinetyDegreeInt (min..max)
UnknownLatitude ::= NinetyDegreeInt (unknown)
Longitude ::= OneEightyDegreeInt
OneEightyDegreeInt ::= INTEGER {
min (-1799999999),
max ( 1800000000),
unknown ( 1800000001)
} (-1799999999..1800000001)
KnownLongitude ::= OneEightyDegreeInt (min..max)
UnknownLongitude ::= OneEightyDegreeInt (unknown)
Elevation ::= ElevInt
ElevInt ::= Uint16
MissingCrlIdentifier ::= SEQUENCE {
cracaId HashedId3,
crlSeries CrlSeries,
...
}
CrlSeries ::= Uint16
EncryptionKey ::= CHOICE {
public PublicEncryptionKey,
symmetric SymmetricEncryptionKey
}
SymmetricEncryptionKey ::= CHOICE {
aes128Ccm OCTET STRING(SIZE(16)),
...,
sm4Ccm OCTET STRING(SIZE(16))
}
PublicEncryptionKey ::= SEQUENCE {
supportedSymmAlg SymmAlgorithm,
publicKey BasePublicEncryptionKey
}
SymmAlgorithm ::= ENUMERATED {
aes128Ccm,
...,
sm4Ccm
}
BasePublicEncryptionKey ::= CHOICE {
eciesNistP256 EccP256CurvePoint,
eciesBrainpoolP256r1 EccP256CurvePoint,
...,
ecencSm2 EccP256CurvePoint
}
EccP256CurvePoint ::= CHOICE {
x-only OCTET STRING(SIZE (32)),
fill NULL,
compressed-y-0 OCTET STRING(SIZE (32)),
compressed-y-1 OCTET STRING(SIZE (32)),
uncompressedP256 SEQUENCE {
x OCTET STRING(SIZE (32)),
y OCTET STRING(SIZE (32))
}
}
EccP384CurvePoint ::= CHOICE {
x-only OCTET STRING(SIZE (48)),
fill NULL,
compressed-y-0 OCTET STRING(SIZE (48)),
compressed-y-1 OCTET STRING(SIZE (48)),
uncompressedP384 SEQUENCE {
x OCTET STRING(SIZE (48)),
y OCTET STRING(SIZE (48))
}
}
PduFunctionalType ::= INTEGER (0..255)
tlsHandshake PduFunctionalType ::= 1
iso21177ExtendedAuth PduFunctionalType ::= 2
SignerIdentifier ::= CHOICE {
digest HashedId8,
certificate SequenceOfCertificate,
self NULL,
...
}
HashedId3 ::= OCTET STRING(SIZE (3))
SequenceOfHashedId3 ::= SEQUENCE OF HashedId3
HashedId8 ::= OCTET STRING(SIZE (8))
HashedId10 ::= OCTET STRING(SIZE (10))
Signature ::= CHOICE {
ecdsaNistP256Signature EcdsaP256Signature,
ecdsaBrainpoolP256r1Signature EcdsaP256Signature,
...,
ecdsaBrainpoolP384r1Signature EcdsaP384Signature,
sm2Signature EcsigP256Signature
}
EcdsaP256Signature ::= SEQUENCE {
rSig EccP256CurvePoint,
sSig OCTET STRING(SIZE (32))
}
EcdsaP384Signature ::= SEQUENCE {
rSig EccP384CurvePoint,
sSig OCTET STRING(SIZE (48))
}
EcsigP256Signature ::= SEQUENCE {
rSig OCTET STRING(SIZE (32)),
sSig OCTET STRING(SIZE (32))
}
EncryptedData ::= SEQUENCE {
recipients SequenceOfRecipientInfo,
ciphertext SymmetricCiphertext
}
RecipientInfo ::= CHOICE {
pskRecipInfo PreSharedKeyRecipientInfo,
symmRecipInfo SymmRecipientInfo,
certRecipInfo PKRecipientInfo,
signedDataRecipInfo PKRecipientInfo,
rekRecipInfo PKRecipientInfo
}
SequenceOfRecipientInfo ::= SEQUENCE OF RecipientInfo
PreSharedKeyRecipientInfo ::= HashedId8
SymmRecipientInfo ::= SEQUENCE {
recipientId HashedId8,
encKey SymmetricCiphertext
}
PKRecipientInfo ::= SEQUENCE {
recipientId HashedId8,
encKey EncryptedDataEncryptionKey
}
EncryptedDataEncryptionKey ::= CHOICE {
eciesNistP256 EciesP256EncryptedKey,
eciesBrainpoolP256r1 EciesP256EncryptedKey,
...,
ecencSm256 EcencP256EncryptedKey
}
EciesP256EncryptedKey ::= SEQUENCE {
v EccP256CurvePoint,
c OCTET STRING(SIZE (16)),
t OCTET STRING(SIZE (16))
}
EcencP256EncryptedKey ::= SEQUENCE {
v EccP256CurvePoint,
c OCTET STRING(SIZE (16)),
t OCTET STRING(SIZE (32))
}
SymmetricCiphertext ::= CHOICE {
aes128ccm One28BitCcmCiphertext,
...,
sm4Ccm One28BitCcmCiphertext
}
One28BitCcmCiphertext ::= SEQUENCE {
nonce OCTET STRING(SIZE (12)),
ccmCiphertext Opaque
}
Countersignature ::= V2XSecData (WITH COMPONENTS {...,
content (WITH COMPONENTS {...,
signedData (WITH COMPONENTS {...,
tbsData (WITH COMPONENTS {...,
payload (WITH COMPONENTS {...,
data ABSENT,
extDataHash PRESENT
}),
headerInfo (WITH COMPONENTS {...,
generationTime PRESENT,
expiryTime ABSENT,
generationLocation ABSENT,
p2pcdLearningRequest ABSENT,
missingCrlIdentifier ABSENT,
encryptionKey ABSENT
})
})
})
})
})
-- 数字证书和证书管理数据格式
Certificate ::= CertificateBase (ImplicitCertificate | ExplicitCertificate)
SequenceOfCertificate ::= SEQUENCE OF Certificate
CertificateBase ::= SEQUENCE {
version Uint8(3),
type CertificateType,
issuer IssuerIdentifier,
toBeSigned ToBeSignedCertificate,
signature Signature OPTIONAL
}
CertificateType ::= ENUMERATED {
explicit,
implicit,
others,
...
}
ImplicitCertificate ::= CertificateBase (WITH COMPONENTS {...,
type(implicit),
toBeSigned(WITH COMPONENTS {...,
verifyKeyIndicator(WITH COMPONENTS {reconstructionValue})
}),
signature ABSENT
})
ExplicitCertificate ::= CertificateBase (WITH COMPONENTS {...,
type(explicit),
toBeSigned(WITH COMPONENTS {...,
verifyKeyIndicator(WITH COMPONENTS {verificationKey})
}),
signature PRESENT
})
IssuerIdentifier ::= CHOICE {
sha256AndDigest HashedId8,
self HashAlgorithm,
...,
sha384AndDigest HashedId8,
sm3AndDigest HashedId8
}
ToBeSignedCertificate ::= SEQUENCE {
id CertificateId,
cracaId HashedId3,
crlSeries CrlSeries,
validityPeriod ValidityPeriod,
region GeographicRegion OPTIONAL,
assuranceLevel SubjectAssurance OPTIONAL,
appPermissions SequenceOfPsidSsp OPTIONAL,
certIssuePermissions SequenceOfPsidGroupPermissions OPTIONAL,
certRequestPermissions SequenceOfPsidGroupPermissions OPTIONAL,
canRequestRollover NULL OPTIONAL,
encryptionKey PublicEncryptionKey OPTIONAL,
verifyKeyIndicator VerificationKeyIndicator OPTIONAL,
...
} (WITH COMPONENTS {..., appPermissions PRESENT} |
WITH COMPONENTS {..., certIssuePermissions PRESENT} |
WITH COMPONENTS {..., certRequestPermissions PRESENT})
CertificateId ::= CHOICE {
linkageData LinkageData,
name Hostname,
binaryId OCTET STRING(SIZE (1..64)),
none NULL,
...
}
LinkageData ::= SEQUENCE {
iCert IValue,
linkage-value LinkageValue,
group-linkage-value GroupLinkageValue OPTIONAL
}
LinkageValue ::= OCTET STRING(SIZE (9))
-- 提供了类似于 json 的解析格式
GroupLinkageValue ::= SEQUENCE {
jValue OCTET STRING(SIZE (4)),
value OCTET STRING(SIZE (9))
}
Hostname ::= UTF8String(SIZE(0..255))
ValidityPeriod ::= SEQUENCE {
start Time32,
duration Duration
}
Time32 ::= Uint32
Duration ::= CHOICE {
microseconds Uint16,
milliseconds Uint16,
seconds Uint16,
minutes Uint16,
hours Uint16,
sixtyHours Uint16,
years Uint16
}
GeographicRegion ::= CHOICE {
circularRegion CircularRegion,
rectangularRegion SequenceOfRectangularRegion,
polygonalRegion PolygonalRegion,
identifiedRegion SequenceOfIdentifiedRegion,
...
}
CircularRegion ::= SEQUENCE {
center TwoDLocation,
radius Uint16
}
TwoDLocation ::= SEQUENCE {
latitude Latitude,
longitude Longitude
}
RectangularRegion ::= SEQUENCE {
northWest TwoDLocation,
southEast TwoDLocation
}
SequenceOfRectangularRegion ::= SEQUENCE OF RectangularRegion
-- 也可以将 SIZE 属性用圆括号括起来
PolygonalRegion ::= SEQUENCE SIZE(3..MAX) OF TwoDLocation
IdentifiedRegion ::= CHOICE {
countryOnly CountryOnly,
countryAndRegions CountryAndRegions,
countryAndSubregions CountryAndSubregions,
...
}
SequenceOfIdentifiedRegion ::= SEQUENCE OF IdentifiedRegion
CountryOnly ::= Uint16
CountryAndRegions ::= SEQUENCE {
countryOnly CountryOnly,
regions SequenceOfUint8
}
CountryAndSubregions ::= SEQUENCE {
country CountryOnly,
regionAndSubregions SequenceOfRegionAndSubregions
}
RegionAndSubregions ::= SEQUENCE {
region Uint8,
subregions SequenceOfUint16
}
SequenceOfRegionAndSubregions ::= SEQUENCE OF RegionAndSubregions
SubjectAssurance ::= OCTET STRING(SIZE(1))
PsidSsp ::= SEQUENCE {
psid Psid,
ssp ServiceSpecificPermissions OPTIONAL
}
SequenceOfPsidSsp ::= SEQUENCE OF PsidSsp
ServiceSpecificPermissions ::= CHOICE {
opaque OCTET STRING(SIZE(0..MAX)),
...,
bitmapSsp BitmapSsp
}
BitmapSsp ::= OCTET STRING(SIZE(0..31))
PsidGroupPermissions ::= SEQUENCE {
subjectPermissions SubjectPermissions,
minChainLength INTEGER DEFAULT 1,
chainLengthRange INTEGER DEFAULT 0,
eeType EndEntityType DEFAULT {app}
}
SequenceOfPsidGroupPermissions ::= SEQUENCE OF PsidGroupPermissions
SubjectPermissions ::= CHOICE {
explicit SequenceOfPsidSspRange,
all NULL,
...
}
EndEntityType ::= BIT STRING{app(0), enroll(1)} (SIZE (8)) (ALL EXCEPT{})
PsidSspRange ::= SEQUENCE {
psid Psid,
sspRange SspRange OPTIONAL
}
SequenceOfPsidSspRange ::= SEQUENCE OF PsidSspRange
SspRange ::= CHOICE {
opaque SequenceOfOctetString,
all NULL,
...,
bitmapSspRange BitmapSspRange
}
BitmapSspRange ::= SEQUENCE {
sspValue OCTET STRING(SIZE (1..32)),
sspBitmask OCTET STRING(SIZE (1..32))
}
VerificationKeyIndicator ::= CHOICE {
verificationKey PublicVerificationKey,
reconstructionValue EccP256CurvePoint,
...
}
PublicVerificationKey ::= CHOICE {
ecdsaNistP256Signature EccP256CurvePoint,
ecdsaBrainpoolP256r1 EccP256CurvePoint,
...,
ecdsaBrainpoolP384r1 EccP384CurvePoint,
ecsigSm2 EccP256CurvePoint
}
END
AsnGbBase DEFINITIONS AUTOMATIC TAGS ::= BEGIN
EXPORTS ALL;
IMPORTS
Uint8,
SignedData,
HashedId8,
Opaque
FROM MyModule;
EccCurve ::= ENUMERATED {
sgdsm2,
nistP256,
brainpoolP256r1
}
ECCPoint ::= CHOICE {
x-only OCTET STRING(SIZE(32)),
fill NULL,
compressed-y-0 OCTET STRING(SIZE(32)),
compressed-y-1 OCTET STRING(SIZE(32)),
uncompressed SEQUENCE {
x OCTET STRING(SIZE(32)),
y OCTET STRING(SIZE(32))
}
}
HashAlgorithmGb ::= ENUMERATED {
sgdsm3,
sha256,
sha3-256,
...
}
PreSharedKeyRecipientInfo ::= SEQUENCE {
hashAlg HashAlgorithmGb,
symKeyHash HashedId8
}
SymmRecipInfo ::= SEQUENCE {
hashAlg HashAlgorithmGb,
recipientId HashedId8,
encKey SymmetricCipherText
}
EciesEncryptedKey ::= SEQUENCE {
eccCurve EccCurve,
v ECCPoint,
c OCTET STRING(SIZE(16)),
t OCTET STRING(SIZE(32))
}
PKRecipientInfo ::= SEQUENCE {
hashAlg HashAlgorithmGb,
recipientId HashedId8,
kek EciesEncryptedKey
}
RecipientInfo ::= CHOICE {
pskRecipientInfo PreSharedKeyRecipientInfo,
symmRecipInfo SymmRecipInfo,
certRecipInfo PKRecipientInfo,
signedDataRecipInfo PKRecipientInfo
}
SequenceOfRecipientInfo ::= SEQUENCE OF RecipientInfo
CipherText ::= Opaque
SM4CipherText ::= SEQUENCE {
iv OCTET STRING(SIZE(16)),
cipher CipherText
}
AesCcmCipherText ::= SEQUENCE {
nonce OCTET STRING(SIZE(12)),
cipher CipherText
}
SymmetricCipherText ::= CHOICE {
sm4Ecb CipherText,
sm4Cbc SM4CipherText,
sm4Cfb SM4CipherText,
sm4Ofb SM4CipherText,
aesCcm AesCcmCipherText
}
EncryptedData ::= SEQUENCE {
recipients SequenceOfRecipientInfo,
cipherText SymmetricCipherText
}
PayloadGb ::= CHOICE {
unSecuredData Opaque,
signedData SignedData,
encData EncryptedData
}
SecureMessageGb ::= SEQUENCE {
version Uint8,
payload PayloadGb
}
END
AsnCertEnroll DEFINITIONS AUTOMATIC TAGS ::= BEGIN
EXPORTS ALL;
IMPORTS
Certificate,
Signature,
GeographicRegion,
SubjectAssurance
FROM MyModule
EccCurve,
EccPoint
FROM AsnGbBase;
SequenceOfitsAidList ::= SEQUENCE OF ItsAid
ItsAid ::= Uint64
SequenceOfitsAidSspList ::= SEQUENCE OF ItsAidSsp
ItsAidSsp ::= SEQUENCE {
itsAid ItsAid,
serviceSpecificPermissions OCTET STRING(SIZE(1..32))
}
PublicVerifyKey ::= SEQUENCE {
curve EccCurve,
key ECCPoint
}
EnrolmentCertRequest ::= SEQUENCE {
subjectName OCTET STRING(SIZE(0..32)),
moduleId OCTET STRING(SIZE(0..32)),
region GeographicRegion OPTIONAL,
verificationKey PublicVerifyKey,
assuranceLevel SubjectAssurance OPTIONAL,
itsAidList SequenceOfitsAidList OPTIONAL,
itsAidSspList SequenceOfitsAidSspList
}
PseudonymCertRequestDn ::= SEQUENCE {
subjectName OCTET STRING(SIZE(0..32)),
moduleId OCTET STRING(SIZE(0..32)),
region GeographicRegion OPTIONAL,
assuranceLevel SubjectAssurance OPTIONAL,
itsAidList SequenceOfitsAidList OPTIONAL,
itsAidSspList SequenceOfitsAidSspList OPTIONAL,
verificationKey PublicVerifyKey,
enrollmentCert Certificate
}
PseudonymCertRequest ::= SEQUENCE {
subjectName OCTET STRING(SIZE(0..32)),
moduleId OCTET STRING(SIZE(0..32)),
region GeographicRegion OPTIONAL,
assuranceLevel SubjectAssurance OPTIONAL,
itsAidList SequenceOfitsAidList OPTIONAL,
itsAidSspList SequenceOfitsAidSspList OPTIONAL,
verificationKey PublicVerifyKey,
enrollmentCert Certificate,
signature Signature
}
END