1b528cefcSMark MurrayA Layman's Guide to a Subset of ASN.1, BER, and DER 2b528cefcSMark Murray 3b528cefcSMark MurrayAn RSA Laboratories Technical Note 4b528cefcSMark MurrayBurton S. Kaliski Jr. 5b528cefcSMark MurrayRevised November 1, 1993 6b528cefcSMark Murray 7b528cefcSMark Murray 8b528cefcSMark MurraySupersedes June 3, 1991 version, which was also published as 9b528cefcSMark MurrayNIST/OSI Implementors' Workshop document SEC-SIG-91-17. 10b528cefcSMark MurrayPKCS documents are available by electronic mail to 11b528cefcSMark Murray<pkcs@rsa.com>. 12b528cefcSMark Murray 13b528cefcSMark MurrayCopyright (C) 1991-1993 RSA Laboratories, a division of RSA 14b528cefcSMark MurrayData Security, Inc. License to copy this document is granted 15b528cefcSMark Murrayprovided that it is identified as "RSA Data Security, Inc. 16b528cefcSMark MurrayPublic-Key Cryptography Standards (PKCS)" in all material 17b528cefcSMark Murraymentioning or referencing this document. 18b528cefcSMark Murray003-903015-110-000-000 19b528cefcSMark Murray 20b528cefcSMark Murray 21b528cefcSMark MurrayAbstract. This note gives a layman's introduction to a 22b528cefcSMark Murraysubset of OSI's Abstract Syntax Notation One (ASN.1), Basic 23b528cefcSMark MurrayEncoding Rules (BER), and Distinguished Encoding Rules 24b528cefcSMark Murray(DER). The particular purpose of this note is to provide 25b528cefcSMark Murraybackground material sufficient for understanding and 26b528cefcSMark Murrayimplementing the PKCS family of standards. 27b528cefcSMark Murray 28b528cefcSMark Murray 29b528cefcSMark Murray1. Introduction 30b528cefcSMark Murray 31b528cefcSMark MurrayIt is a generally accepted design principle that abstraction 32b528cefcSMark Murrayis a key to managing software development. With abstraction, 33b528cefcSMark Murraya designer can specify a part of a system without concern 34b528cefcSMark Murrayfor how the part is actually implemented or represented. 35b528cefcSMark MurraySuch a practice leaves the implementation open; it 36b528cefcSMark Murraysimplifies the specification; and it makes it possible to 37b528cefcSMark Murraystate "axioms" about the part that can be proved when the 38b528cefcSMark Murraypart is implemented, and assumed when the part is employed 39b528cefcSMark Murrayin another, higher-level part. Abstraction is the hallmark 40b528cefcSMark Murrayof most modern software specifications. 41b528cefcSMark Murray 42b528cefcSMark MurrayOne of the most complex systems today, and one that also 43b528cefcSMark Murrayinvolves a great deal of abstraction, is Open Systems 44b528cefcSMark MurrayInterconnection (OSI, described in X.200). OSI is an 45b528cefcSMark Murrayinternationally standardized architecture that governs the 46b528cefcSMark Murrayinterconnection of computers from the physical layer up to 47b528cefcSMark Murraythe user application layer. Objects at higher layers are 48b528cefcSMark Murraydefined abstractly and intended to be implemented with 49b528cefcSMark Murrayobjects at lower layers. For instance, a service at one 50b528cefcSMark Murraylayer may require transfer of certain abstract objects 51b528cefcSMark Murraybetween computers; a lower layer may provide transfer 52b528cefcSMark Murrayservices for strings of ones and zeroes, using encoding 53b528cefcSMark Murrayrules to transform the abstract objects into such strings. 54b528cefcSMark MurrayOSI is called an open system because it supports many 55b528cefcSMark Murraydifferent implementations of the services at each layer. 56b528cefcSMark Murray 57b528cefcSMark MurrayOSI's method of specifying abstract objects is called ASN.1 58b528cefcSMark Murray(Abstract Syntax Notation One, defined in X.208), and one 59b528cefcSMark Murrayset of rules for representing such objects as strings of 60b528cefcSMark Murrayones and zeros is called the BER (Basic Encoding Rules, 61b528cefcSMark Murraydefined in X.209). ASN.1 is a flexible notation that allows 62b528cefcSMark Murrayone to define a variety data types, from simple types such 63b528cefcSMark Murrayas integers and bit strings to structured types such as sets 64b528cefcSMark Murrayand sequences, as well as complex types defined in terms of 65b528cefcSMark Murrayothers. BER describes how to represent or encode values of 66b528cefcSMark Murrayeach ASN.1 type as a string of eight-bit octets. There is 67b528cefcSMark Murraygenerally more than one way to BER-encode a given value. 68b528cefcSMark MurrayAnother set of rules, called the Distinguished Encoding 69b528cefcSMark MurrayRules (DER), which is a subset of BER, gives a unique 70b528cefcSMark Murrayencoding to each ASN.1 value. 71b528cefcSMark Murray 72b528cefcSMark MurrayThe purpose of this note is to describe a subset of ASN.1, 73b528cefcSMark MurrayBER and DER sufficient to understand and implement one OSI- 74b528cefcSMark Murraybased application, RSA Data Security, Inc.'s Public-Key 75b528cefcSMark MurrayCryptography Standards. The features described include an 76b528cefcSMark Murrayoverview of ASN.1, BER, and DER and an abridged list of 77b528cefcSMark MurrayASN.1 types and their BER and DER encodings. Sections 2-4 78b528cefcSMark Murraygive an overview of ASN.1, BER, and DER, in that order. 79b528cefcSMark MurraySection 5 lists some ASN.1 types, giving their notation, 80b528cefcSMark Murrayspecific encoding rules, examples, and comments about their 81b528cefcSMark Murrayapplication to PKCS. Section 6 concludes with an example, 82b528cefcSMark MurrayX.500 distinguished names. 83b528cefcSMark Murray 84b528cefcSMark MurrayAdvanced features of ASN.1, such as macros, are not 85b528cefcSMark Murraydescribed in this note, as they are not needed to implement 86b528cefcSMark MurrayPKCS. For information on the other features, and for more 87b528cefcSMark Murraydetail generally, the reader is referred to CCITT 88b528cefcSMark MurrayRecommendations X.208 and X.209, which define ASN.1 and BER. 89b528cefcSMark Murray 90b528cefcSMark MurrayTerminology and notation. In this note, an octet is an eight- 91b528cefcSMark Murraybit unsigned integer. Bit 8 of the octet is the most 92b528cefcSMark Murraysignificant and bit 1 is the least significant. 93b528cefcSMark Murray 94b528cefcSMark MurrayThe following meta-syntax is used for in describing ASN.1 95b528cefcSMark Murraynotation: 96b528cefcSMark Murray 97b528cefcSMark Murray BIT monospace denotes literal characters in the type 98b528cefcSMark Murray and value notation; in examples, it generally 99b528cefcSMark Murray denotes an octet value in hexadecimal 100b528cefcSMark Murray 101b528cefcSMark Murray n1 bold italics denotes a variable 102b528cefcSMark Murray 103b528cefcSMark Murray [] bold square brackets indicate that a term is 104b528cefcSMark Murray optional 105b528cefcSMark Murray 106b528cefcSMark Murray {} bold braces group related terms 107b528cefcSMark Murray 108b528cefcSMark Murray | bold vertical bar delimits alternatives with a 109b528cefcSMark Murray group 110b528cefcSMark Murray 111b528cefcSMark Murray ... bold ellipsis indicates repeated occurrences 112b528cefcSMark Murray 113b528cefcSMark Murray = bold equals sign expresses terms as subterms 114b528cefcSMark Murray 115b528cefcSMark Murray 116b528cefcSMark Murray2. Abstract Syntax Notation One 117b528cefcSMark Murray 118b528cefcSMark MurrayAbstract Syntax Notation One, abbreviated ASN.1, is a 119b528cefcSMark Murraynotation for describing abstract types and values. 120b528cefcSMark Murray 121b528cefcSMark MurrayIn ASN.1, a type is a set of values. For some types, there 122b528cefcSMark Murrayare a finite number of values, and for other types there are 123b528cefcSMark Murrayan infinite number. A value of a given ASN.1 type is an 124b528cefcSMark Murrayelement of the type's set. ASN.1 has four kinds of type: 125b528cefcSMark Murraysimple types, which are "atomic" and have no components; 126b528cefcSMark Murraystructured types, which have components; tagged types, which 127b528cefcSMark Murrayare derived from other types; and other types, which include 128b528cefcSMark Murraythe CHOICE type and the ANY type. Types and values can be 129b528cefcSMark Murraygiven names with the ASN.1 assignment operator (::=) , and 130b528cefcSMark Murraythose names can be used in defining other types and values. 131b528cefcSMark Murray 132b528cefcSMark MurrayEvery ASN.1 type other than CHOICE and ANY has a tag, which 133b528cefcSMark Murrayconsists of a class and a nonnegative tag number. ASN.1 134b528cefcSMark Murraytypes are abstractly the same if and only if their tag 135b528cefcSMark Murraynumbers are the same. In other words, the name of an ASN.1 136b528cefcSMark Murraytype does not affect its abstract meaning, only the tag 137b528cefcSMark Murraydoes. There are four classes of tag: 138b528cefcSMark Murray 139b528cefcSMark Murray Universal, for types whose meaning is the same in all 140b528cefcSMark Murray applications; these types are only defined in 141b528cefcSMark Murray X.208. 142b528cefcSMark Murray 143b528cefcSMark Murray Application, for types whose meaning is specific to an 144b528cefcSMark Murray application, such as X.500 directory services; 145b528cefcSMark Murray types in two different applications may have the 146b528cefcSMark Murray same application-specific tag and different 147b528cefcSMark Murray meanings. 148b528cefcSMark Murray 149b528cefcSMark Murray Private, for types whose meaning is specific to a given 150b528cefcSMark Murray enterprise. 151b528cefcSMark Murray 152b528cefcSMark Murray Context-specific, for types whose meaning is specific 153b528cefcSMark Murray to a given structured type; context-specific tags 154b528cefcSMark Murray are used to distinguish between component types 155b528cefcSMark Murray with the same underlying tag within the context of 156b528cefcSMark Murray a given structured type, and component types in 157b528cefcSMark Murray two different structured types may have the same 158b528cefcSMark Murray tag and different meanings. 159b528cefcSMark Murray 160b528cefcSMark MurrayThe types with universal tags are defined in X.208, which 161b528cefcSMark Murrayalso gives the types' universal tag numbers. Types with 162b528cefcSMark Murrayother tags are defined in many places, and are always 163b528cefcSMark Murrayobtained by implicit or explicit tagging (see Section 2.3). 164b528cefcSMark MurrayTable 1 lists some ASN.1 types and their universal-class 165b528cefcSMark Murraytags. 166b528cefcSMark Murray 167b528cefcSMark Murray Type Tag number Tag number 168b528cefcSMark Murray (decimal) (hexadecimal) 169b528cefcSMark Murray INTEGER 2 02 170b528cefcSMark Murray BIT STRING 3 03 171b528cefcSMark Murray OCTET STRING 4 04 172b528cefcSMark Murray NULL 5 05 173b528cefcSMark Murray OBJECT IDENTIFIER 6 06 174b528cefcSMark Murray SEQUENCE and SEQUENCE OF 16 10 175b528cefcSMark Murray SET and SET OF 17 11 176b528cefcSMark Murray PrintableString 19 13 177b528cefcSMark Murray T61String 20 14 178b528cefcSMark Murray IA5String 22 16 179b528cefcSMark Murray UTCTime 23 17 180b528cefcSMark Murray 181b528cefcSMark Murray Table 1. Some types and their universal-class tags. 182b528cefcSMark Murray 183b528cefcSMark MurrayASN.1 types and values are expressed in a flexible, 184b528cefcSMark Murrayprogramming-language-like notation, with the following 185b528cefcSMark Murrayspecial rules: 186b528cefcSMark Murray 187b528cefcSMark Murray o Layout is not significant; multiple spaces and 188b528cefcSMark Murray line breaks can be considered as a single space. 189b528cefcSMark Murray 190b528cefcSMark Murray o Comments are delimited by pairs of hyphens (--), 191b528cefcSMark Murray or a pair of hyphens and a line break. 192b528cefcSMark Murray 193b528cefcSMark Murray o Identifiers (names of values and fields) and type 194b528cefcSMark Murray references (names of types) consist of upper- and 195b528cefcSMark Murray lower-case letters, digits, hyphens, and spaces; 196b528cefcSMark Murray identifiers begin with lower-case letters; type 197b528cefcSMark Murray references begin with upper-case letters. 198b528cefcSMark Murray 199b528cefcSMark MurrayThe following four subsections give an overview of simple 200b528cefcSMark Murraytypes, structured types, implicitly and explicitly tagged 201b528cefcSMark Murraytypes, and other types. Section 5 describes specific types 202b528cefcSMark Murrayin more detail. 203b528cefcSMark Murray 204b528cefcSMark Murray 205b528cefcSMark Murray2.1 Simple types 206b528cefcSMark Murray 207b528cefcSMark MurraySimple types are those not consisting of components; they 208b528cefcSMark Murrayare the "atomic" types. ASN.1 defines several; the types 209b528cefcSMark Murraythat are relevant to the PKCS standards are the following: 210b528cefcSMark Murray 211b528cefcSMark Murray BIT STRING, an arbitrary string of bits (ones and 212b528cefcSMark Murray zeroes). 213b528cefcSMark Murray 214b528cefcSMark Murray IA5String, an arbitrary string of IA5 (ASCII) 215b528cefcSMark Murray characters. 216b528cefcSMark Murray 217b528cefcSMark Murray INTEGER, an arbitrary integer. 218b528cefcSMark Murray 219b528cefcSMark Murray NULL, a null value. 220b528cefcSMark Murray 221b528cefcSMark Murray OBJECT IDENTIFIER, an object identifier, which is a 222b528cefcSMark Murray sequence of integer components that identify an 223b528cefcSMark Murray object such as an algorithm or attribute type. 224b528cefcSMark Murray 225b528cefcSMark Murray OCTET STRING, an arbitrary string of octets (eight-bit 226b528cefcSMark Murray values). 227b528cefcSMark Murray 228b528cefcSMark Murray PrintableString, an arbitrary string of printable 229b528cefcSMark Murray characters. 230b528cefcSMark Murray 231b528cefcSMark Murray T61String, an arbitrary string of T.61 (eight-bit) 232b528cefcSMark Murray characters. 233b528cefcSMark Murray 234b528cefcSMark Murray UTCTime, a "coordinated universal time" or Greenwich 235b528cefcSMark Murray Mean Time (GMT) value. 236b528cefcSMark Murray 237b528cefcSMark MurraySimple types fall into two categories: string types and non- 238b528cefcSMark Murraystring types. BIT STRING, IA5String, OCTET STRING, 239b528cefcSMark MurrayPrintableString, T61String, and UTCTime are string types. 240b528cefcSMark Murray 241b528cefcSMark MurrayString types can be viewed, for the purposes of encoding, as 242b528cefcSMark Murrayconsisting of components, where the components are 243b528cefcSMark Murraysubstrings. This view allows one to encode a value whose 244b528cefcSMark Murraylength is not known in advance (e.g., an octet string value 245b528cefcSMark Murrayinput from a file stream) with a constructed, indefinite- 246b528cefcSMark Murraylength encoding (see Section 3). 247b528cefcSMark Murray 248b528cefcSMark MurrayThe string types can be given size constraints limiting the 249b528cefcSMark Murraylength of values. 250b528cefcSMark Murray 251b528cefcSMark Murray 252b528cefcSMark Murray2.2 Structured types 253b528cefcSMark Murray 254b528cefcSMark MurrayStructured types are those consisting of components. ASN.1 255b528cefcSMark Murraydefines four, all of which are relevant to the PKCS 256b528cefcSMark Murraystandards: 257b528cefcSMark Murray 258b528cefcSMark Murray SEQUENCE, an ordered collection of one or more types. 259b528cefcSMark Murray 260b528cefcSMark Murray SEQUENCE OF, an ordered collection of zero or more 261b528cefcSMark Murray occurrences of a given type. 262b528cefcSMark Murray 263b528cefcSMark Murray SET, an unordered collection of one or more types. 264b528cefcSMark Murray 265b528cefcSMark Murray SET OF, an unordered collection of zero or more 266b528cefcSMark Murray occurrences of a given type. 267b528cefcSMark Murray 268b528cefcSMark MurrayThe structured types can have optional components, possibly 269b528cefcSMark Murraywith default values. 270b528cefcSMark Murray 271b528cefcSMark Murray 272b528cefcSMark Murray2.3 Implicitly and explicitly tagged types 273b528cefcSMark Murray 274b528cefcSMark MurrayTagging is useful to distinguish types within an 275b528cefcSMark Murrayapplication; it is also commonly used to distinguish 276b528cefcSMark Murraycomponent types within a structured type. For instance, 277b528cefcSMark Murrayoptional components of a SET or SEQUENCE type are typically 278b528cefcSMark Murraygiven distinct context-specific tags to avoid ambiguity. 279b528cefcSMark Murray 280b528cefcSMark MurrayThere are two ways to tag a type: implicitly and explicitly. 281b528cefcSMark Murray 282b528cefcSMark MurrayImplicitly tagged types are derived from other types by 283b528cefcSMark Murraychanging the tag of the underlying type. Implicit tagging is 284b528cefcSMark Murraydenoted by the ASN.1 keywords [class number] IMPLICIT (see 285b528cefcSMark MurraySection 5.1). 286b528cefcSMark Murray 287b528cefcSMark MurrayExplicitly tagged types are derived from other types by 288b528cefcSMark Murrayadding an outer tag to the underlying type. In effect, 289b528cefcSMark Murrayexplicitly tagged types are structured types consisting of 290b528cefcSMark Murrayone component, the underlying type. Explicit tagging is 291b528cefcSMark Murraydenoted by the ASN.1 keywords [class number] EXPLICIT (see 292b528cefcSMark MurraySection 5.2). 293b528cefcSMark Murray 294b528cefcSMark MurrayThe keyword [class number] alone is the same as explicit 295b528cefcSMark Murraytagging, except when the "module" in which the ASN.1 type is 296b528cefcSMark Murraydefined has implicit tagging by default. ("Modules" are 297b528cefcSMark Murrayamong the advanced features not described in this note.) 298b528cefcSMark Murray 299b528cefcSMark MurrayFor purposes of encoding, an implicitly tagged type is 300b528cefcSMark Murrayconsidered the same as the underlying type, except that the 301b528cefcSMark Murraytag is different. An explicitly tagged type is considered 302b528cefcSMark Murraylike a structured type with one component, the underlying 303b528cefcSMark Murraytype. Implicit tags result in shorter encodings, but 304b528cefcSMark Murrayexplicit tags may be necessary to avoid ambiguity if the tag 305b528cefcSMark Murrayof the underlying type is indeterminate (e.g., the 306b528cefcSMark Murrayunderlying type is CHOICE or ANY). 307b528cefcSMark Murray 308b528cefcSMark Murray 309b528cefcSMark Murray2.4 Other types 310b528cefcSMark Murray 311b528cefcSMark MurrayOther types in ASN.1 include the CHOICE and ANY types. The 312b528cefcSMark MurrayCHOICE type denotes a union of one or more alternatives; the 313b528cefcSMark MurrayANY type denotes an arbitrary value of an arbitrary type, 314b528cefcSMark Murraywhere the arbitrary type is possibly defined in the 315b528cefcSMark Murrayregistration of an object identifier or integer value. 316b528cefcSMark Murray 317b528cefcSMark Murray 318b528cefcSMark Murray3. Basic Encoding Rules 319b528cefcSMark Murray 320b528cefcSMark MurrayThe Basic Encoding Rules for ASN.1, abbreviated BER, give 321b528cefcSMark Murrayone or more ways to represent any ASN.1 value as an octet 322b528cefcSMark Murraystring. (There are certainly other ways to represent ASN.1 323b528cefcSMark Murrayvalues, but BER is the standard for interchanging such 324b528cefcSMark Murrayvalues in OSI.) 325b528cefcSMark Murray 326b528cefcSMark MurrayThere are three methods to encode an ASN.1 value under BER, 327b528cefcSMark Murraythe choice of which depends on the type of value and whether 328b528cefcSMark Murraythe length of the value is known. The three methods are 329b528cefcSMark Murrayprimitive, definite-length encoding; constructed, definite- 330b528cefcSMark Murraylength encoding; and constructed, indefinite-length 331b528cefcSMark Murrayencoding. Simple non-string types employ the primitive, 332b528cefcSMark Murraydefinite-length method; structured types employ either of 333b528cefcSMark Murraythe constructed methods; and simple string types employ any 334b528cefcSMark Murrayof the methods, depending on whether the length of the value 335b528cefcSMark Murrayis known. Types derived by implicit tagging employ the 336b528cefcSMark Murraymethod of the underlying type and types derived by explicit 337b528cefcSMark Murraytagging employ the constructed methods. 338b528cefcSMark Murray 339b528cefcSMark MurrayIn each method, the BER encoding has three or four parts: 340b528cefcSMark Murray 341b528cefcSMark Murray Identifier octets. These identify the class and tag 342b528cefcSMark Murray number of the ASN.1 value, and indicate whether 343b528cefcSMark Murray the method is primitive or constructed. 344b528cefcSMark Murray 345b528cefcSMark Murray Length octets. For the definite-length methods, these 346b528cefcSMark Murray give the number of contents octets. For the 347b528cefcSMark Murray constructed, indefinite-length method, these 348b528cefcSMark Murray indicate that the length is indefinite. 349b528cefcSMark Murray 350b528cefcSMark Murray Contents octets. For the primitive, definite-length 351b528cefcSMark Murray method, these give a concrete representation of 352b528cefcSMark Murray the value. For the constructed methods, these 353b528cefcSMark Murray give the concatenation of the BER encodings of the 354b528cefcSMark Murray components of the value. 355b528cefcSMark Murray 356b528cefcSMark Murray End-of-contents octets. For the constructed, indefinite- 357b528cefcSMark Murray length method, these denote the end of the 358b528cefcSMark Murray contents. For the other methods, these are absent. 359b528cefcSMark Murray 360b528cefcSMark MurrayThe three methods of encoding are described in the following 361b528cefcSMark Murraysections. 362b528cefcSMark Murray 363b528cefcSMark Murray 364b528cefcSMark Murray3.1 Primitive, definite-length method 365b528cefcSMark Murray 366b528cefcSMark MurrayThis method applies to simple types and types derived from 367b528cefcSMark Murraysimple types by implicit tagging. It requires that the 368b528cefcSMark Murraylength of the value be known in advance. The parts of the 369b528cefcSMark MurrayBER encoding are as follows: 370b528cefcSMark Murray 371b528cefcSMark MurrayIdentifier octets. There are two forms: low tag number (for 372b528cefcSMark Murraytag numbers between 0 and 30) and high tag number (for tag 373b528cefcSMark Murraynumbers 31 and greater). 374b528cefcSMark Murray 375b528cefcSMark Murray Low-tag-number form. One octet. Bits 8 and 7 specify 376b528cefcSMark Murray the class (see Table 2), bit 6 has value "0," 377b528cefcSMark Murray indicating that the encoding is primitive, and 378b528cefcSMark Murray bits 5-1 give the tag number. 379b528cefcSMark Murray 380b528cefcSMark Murray Class Bit Bit 381b528cefcSMark Murray 8 7 382b528cefcSMark Murray universal 0 0 383b528cefcSMark Murray application 0 1 384b528cefcSMark Murray context-specific 1 0 385b528cefcSMark Murray private 1 1 386b528cefcSMark Murray 387b528cefcSMark Murray Table 2. Class encoding in identifier octets. 388b528cefcSMark Murray 389b528cefcSMark Murray High-tag-number form. Two or more octets. First octet 390b528cefcSMark Murray is as in low-tag-number form, except that bits 5-1 391b528cefcSMark Murray all have value "1." Second and following octets 392b528cefcSMark Murray give the tag number, base 128, most significant 393b528cefcSMark Murray digit first, with as few digits as possible, and 394b528cefcSMark Murray with the bit 8 of each octet except the last set 395b528cefcSMark Murray to "1." 396b528cefcSMark Murray 397b528cefcSMark MurrayLength octets. There are two forms: short (for lengths 398b528cefcSMark Murraybetween 0 and 127), and long definite (for lengths between 0 399b528cefcSMark Murrayand 21008-1). 400b528cefcSMark Murray 401b528cefcSMark Murray Short form. One octet. Bit 8 has value "0" and bits 7-1 402b528cefcSMark Murray give the length. 403b528cefcSMark Murray 404b528cefcSMark Murray Long form. Two to 127 octets. Bit 8 of first octet has 405b528cefcSMark Murray value "1" and bits 7-1 give the number of 406b528cefcSMark Murray additional length octets. Second and following 407b528cefcSMark Murray octets give the length, base 256, most significant 408b528cefcSMark Murray digit first. 409b528cefcSMark Murray 410b528cefcSMark MurrayContents octets. These give a concrete representation of the 411b528cefcSMark Murrayvalue (or the value of the underlying type, if the type is 412b528cefcSMark Murrayderived by implicit tagging). Details for particular types 413b528cefcSMark Murrayare given in Section 5. 414b528cefcSMark Murray 415b528cefcSMark Murray 416b528cefcSMark Murray3.2 Constructed, definite-length method 417b528cefcSMark Murray 418b528cefcSMark MurrayThis method applies to simple string types, structured 419b528cefcSMark Murraytypes, types derived simple string types and structured 420b528cefcSMark Murraytypes by implicit tagging, and types derived from anything 421b528cefcSMark Murrayby explicit tagging. It requires that the length of the 422b528cefcSMark Murrayvalue be known in advance. The parts of the BER encoding are 423b528cefcSMark Murrayas follows: 424b528cefcSMark Murray 425b528cefcSMark MurrayIdentifier octets. As described in Section 3.1, except that 426b528cefcSMark Murraybit 6 has value "1," indicating that the encoding is 427b528cefcSMark Murrayconstructed. 428b528cefcSMark Murray 429b528cefcSMark MurrayLength octets. As described in Section 3.1. 430b528cefcSMark Murray 431b528cefcSMark MurrayContents octets. The concatenation of the BER encodings of 432b528cefcSMark Murraythe components of the value: 433b528cefcSMark Murray 434b528cefcSMark Murray o For simple string types and types derived from 435b528cefcSMark Murray them by implicit tagging, the concatenation of the 436b528cefcSMark Murray BER encodings of consecutive substrings of the 437b528cefcSMark Murray value (underlying value for implicit tagging). 438b528cefcSMark Murray 439b528cefcSMark Murray o For structured types and types derived from them 440b528cefcSMark Murray by implicit tagging, the concatenation of the BER 441b528cefcSMark Murray encodings of components of the value (underlying 442b528cefcSMark Murray value for implicit tagging). 443b528cefcSMark Murray 444b528cefcSMark Murray o For types derived from anything by explicit 445b528cefcSMark Murray tagging, the BER encoding of the underlying value. 446b528cefcSMark Murray 447b528cefcSMark MurrayDetails for particular types are given in Section 5. 448b528cefcSMark Murray 449b528cefcSMark Murray 450b528cefcSMark Murray3.3 Constructed, indefinite-length method 451b528cefcSMark Murray 452b528cefcSMark MurrayThis method applies to simple string types, structured 453b528cefcSMark Murraytypes, types derived simple string types and structured 454b528cefcSMark Murraytypes by implicit tagging, and types derived from anything 455b528cefcSMark Murrayby explicit tagging. It does not require that the length of 456b528cefcSMark Murraythe value be known in advance. The parts of the BER encoding 457b528cefcSMark Murrayare as follows: 458b528cefcSMark Murray 459b528cefcSMark MurrayIdentifier octets. As described in Section 3.2. 460b528cefcSMark Murray 461b528cefcSMark MurrayLength octets. One octet, 80. 462b528cefcSMark Murray 463b528cefcSMark MurrayContents octets. As described in Section 3.2. 464b528cefcSMark Murray 465b528cefcSMark MurrayEnd-of-contents octets. Two octets, 00 00. 466b528cefcSMark Murray 467b528cefcSMark MurraySince the end-of-contents octets appear where an ordinary 468b528cefcSMark MurrayBER encoding might be expected (e.g., in the contents octets 469b528cefcSMark Murrayof a sequence value), the 00 and 00 appear as identifier and 470b528cefcSMark Murraylength octets, respectively. Thus the end-of-contents octets 471b528cefcSMark Murrayis really the primitive, definite-length encoding of a value 472b528cefcSMark Murraywith universal class, tag number 0, and length 0. 473b528cefcSMark Murray 474b528cefcSMark Murray 475b528cefcSMark Murray4. Distinguished Encoding Rules 476b528cefcSMark Murray 477b528cefcSMark MurrayThe Distinguished Encoding Rules for ASN.1, abbreviated DER, 478b528cefcSMark Murrayare a subset of BER, and give exactly one way to represent 479b528cefcSMark Murrayany ASN.1 value as an octet string. DER is intended for 480b528cefcSMark Murrayapplications in which a unique octet string encoding is 481b528cefcSMark Murrayneeded, as is the case when a digital signature is computed 482b528cefcSMark Murrayon an ASN.1 value. DER is defined in Section 8.7 of X.509. 483b528cefcSMark Murray 484b528cefcSMark MurrayDER adds the following restrictions to the rules given in 485b528cefcSMark MurraySection 3: 486b528cefcSMark Murray 487b528cefcSMark Murray 1. When the length is between 0 and 127, the short 488b528cefcSMark Murray form of length must be used 489b528cefcSMark Murray 490b528cefcSMark Murray 2. When the length is 128 or greater, the long form 491b528cefcSMark Murray of length must be used, and the length must be 492b528cefcSMark Murray encoded in the minimum number of octets. 493b528cefcSMark Murray 494b528cefcSMark Murray 3. For simple string types and implicitly tagged 495b528cefcSMark Murray types derived from simple string types, the 496b528cefcSMark Murray primitive, definite-length method must be 497b528cefcSMark Murray employed. 498b528cefcSMark Murray 499b528cefcSMark Murray 4. For structured types, implicitly tagged types 500b528cefcSMark Murray derived from structured types, and explicitly 501b528cefcSMark Murray tagged types derived from anything, the 502b528cefcSMark Murray constructed, definite-length method must be 503b528cefcSMark Murray employed. 504b528cefcSMark Murray 505b528cefcSMark MurrayOther restrictions are defined for particular types (such as 506b528cefcSMark MurrayBIT STRING, SEQUENCE, SET, and SET OF), and can be found in 507b528cefcSMark MurraySection 5. 508b528cefcSMark Murray 509b528cefcSMark Murray 510b528cefcSMark Murray5. Notation and encodings for some types 511b528cefcSMark Murray 512b528cefcSMark MurrayThis section gives the notation for some ASN.1 types and 513b528cefcSMark Murraydescribes how to encode values of those types under both BER 514b528cefcSMark Murrayand DER. 515b528cefcSMark Murray 516b528cefcSMark MurrayThe types described are those presented in Section 2. They 517b528cefcSMark Murrayare listed alphabetically here. 518b528cefcSMark Murray 519b528cefcSMark MurrayEach description includes ASN.1 notation, BER encoding, and 520b528cefcSMark MurrayDER encoding. The focus of the encodings is primarily on the 521b528cefcSMark Murraycontents octets; the tag and length octets follow Sections 3 522b528cefcSMark Murrayand 4. The descriptions also explain where each type is used 523b528cefcSMark Murrayin PKCS and related standards. ASN.1 notation is generally 524b528cefcSMark Murrayonly for types, although for the type OBJECT IDENTIFIER, 525b528cefcSMark Murrayvalue notation is given as well. 526b528cefcSMark Murray 527b528cefcSMark Murray 528b528cefcSMark Murray5.1 Implicitly tagged types 529b528cefcSMark Murray 530b528cefcSMark MurrayAn implicitly tagged type is a type derived from another 531b528cefcSMark Murraytype by changing the tag of the underlying type. 532b528cefcSMark Murray 533b528cefcSMark MurrayImplicit tagging is used for optional SEQUENCE components 534b528cefcSMark Murraywith underlying type other than ANY throughout PKCS, and for 535b528cefcSMark Murraythe extendedCertificate alternative of PKCS #7's 536b528cefcSMark MurrayExtendedCertificateOrCertificate type. 537b528cefcSMark Murray 538b528cefcSMark MurrayASN.1 notation: 539b528cefcSMark Murray 540b528cefcSMark Murray[[class] number] IMPLICIT Type 541b528cefcSMark Murray 542b528cefcSMark Murrayclass = UNIVERSAL | APPLICATION | PRIVATE 543b528cefcSMark Murray 544b528cefcSMark Murraywhere Type is a type, class is an optional class name, and 545b528cefcSMark Murraynumber is the tag number within the class, a nonnegative 546b528cefcSMark Murrayinteger. 547b528cefcSMark Murray 548b528cefcSMark MurrayIn ASN.1 "modules" whose default tagging method is implicit 549b528cefcSMark Murraytagging, the notation [[class] number] Type is also 550b528cefcSMark Murrayacceptable, and the keyword IMPLICIT is implied. (See 551b528cefcSMark MurraySection 2.3.) For definitions stated outside a module, the 552b528cefcSMark Murrayexplicit inclusion of the keyword IMPLICIT is preferable to 553b528cefcSMark Murrayprevent ambiguity. 554b528cefcSMark Murray 555b528cefcSMark MurrayIf the class name is absent, then the tag is context- 556b528cefcSMark Murrayspecific. Context-specific tags can only appear in a 557b528cefcSMark Murraycomponent of a structured or CHOICE type. 558b528cefcSMark Murray 559b528cefcSMark MurrayExample: PKCS #8's PrivateKeyInfo type has an optional 560b528cefcSMark Murrayattributes component with an implicit, context-specific tag: 561b528cefcSMark Murray 562b528cefcSMark MurrayPrivateKeyInfo ::= SEQUENCE { 563b528cefcSMark Murray version Version, 564b528cefcSMark Murray privateKeyAlgorithm PrivateKeyAlgorithmIdentifier, 565b528cefcSMark Murray privateKey PrivateKey, 566b528cefcSMark Murray attributes [0] IMPLICIT Attributes OPTIONAL } 567b528cefcSMark Murray 568b528cefcSMark MurrayHere the underlying type is Attributes, the class is absent 569b528cefcSMark Murray(i.e., context-specific), and the tag number within the 570b528cefcSMark Murrayclass is 0. 571b528cefcSMark Murray 572b528cefcSMark MurrayBER encoding. Primitive or constructed, depending on the 573b528cefcSMark Murrayunderlying type. Contents octets are as for the BER encoding 574b528cefcSMark Murrayof the underlying value. 575b528cefcSMark Murray 576b528cefcSMark MurrayExample: The BER encoding of the attributes component of a 577b528cefcSMark MurrayPrivateKeyInfo value is as follows: 578b528cefcSMark Murray 579b528cefcSMark Murray o the identifier octets are 80 if the underlying 580b528cefcSMark Murray Attributes value has a primitive BER encoding and 581b528cefcSMark Murray a0 if the underlying Attributes value has a 582b528cefcSMark Murray constructed BER encoding 583b528cefcSMark Murray 584b528cefcSMark Murray o the length and contents octets are the same as the 585b528cefcSMark Murray length and contents octets of the BER encoding of 586b528cefcSMark Murray the underlying Attributes value 587b528cefcSMark Murray 588b528cefcSMark MurrayDER encoding. Primitive or constructed, depending on the 589b528cefcSMark Murrayunderlying type. Contents octets are as for the DER encoding 590b528cefcSMark Murrayof the underlying value. 591b528cefcSMark Murray 592b528cefcSMark Murray 593b528cefcSMark Murray5.2 Explicitly tagged types 594b528cefcSMark Murray 595b528cefcSMark MurrayExplicit tagging denotes a type derived from another type by 596b528cefcSMark Murrayadding an outer tag to the underlying type. 597b528cefcSMark Murray 598b528cefcSMark MurrayExplicit tagging is used for optional SEQUENCE components 599b528cefcSMark Murraywith underlying type ANY throughout PKCS, and for the 600b528cefcSMark Murrayversion component of X.509's Certificate type. 601b528cefcSMark Murray 602b528cefcSMark MurrayASN.1 notation: 603b528cefcSMark Murray 604b528cefcSMark Murray[[class] number] EXPLICIT Type 605b528cefcSMark Murray 606b528cefcSMark Murrayclass = UNIVERSAL | APPLICATION | PRIVATE 607b528cefcSMark Murray 608b528cefcSMark Murraywhere Type is a type, class is an optional class name, and 609b528cefcSMark Murraynumber is the tag number within the class, a nonnegative 610b528cefcSMark Murrayinteger. 611b528cefcSMark Murray 612b528cefcSMark MurrayIf the class name is absent, then the tag is context- 613b528cefcSMark Murrayspecific. Context-specific tags can only appear in a 614b528cefcSMark Murraycomponent of a SEQUENCE, SET or CHOICE type. 615b528cefcSMark Murray 616b528cefcSMark MurrayIn ASN.1 "modules" whose default tagging method is explicit 617b528cefcSMark Murraytagging, the notation [[class] number] Type is also 618b528cefcSMark Murrayacceptable, and the keyword EXPLICIT is implied. (See 619b528cefcSMark MurraySection 2.3.) For definitions stated outside a module, the 620b528cefcSMark Murrayexplicit inclusion of the keyword EXPLICIT is preferable to 621b528cefcSMark Murrayprevent ambiguity. 622b528cefcSMark Murray 623b528cefcSMark MurrayExample 1: PKCS #7's ContentInfo type has an optional 624b528cefcSMark Murraycontent component with an explicit, context-specific tag: 625b528cefcSMark Murray 626b528cefcSMark MurrayContentInfo ::= SEQUENCE { 627b528cefcSMark Murray contentType ContentType, 628b528cefcSMark Murray content 629b528cefcSMark Murray [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL } 630b528cefcSMark Murray 631b528cefcSMark MurrayHere the underlying type is ANY DEFINED BY contentType, the 632b528cefcSMark Murrayclass is absent (i.e., context-specific), and the tag number 633b528cefcSMark Murraywithin the class is 0. 634b528cefcSMark Murray 635b528cefcSMark MurrayExample 2: X.509's Certificate type has a version component 636b528cefcSMark Murraywith an explicit, context-specific tag, where the EXPLICIT 637b528cefcSMark Murraykeyword is omitted: 638b528cefcSMark Murray 639b528cefcSMark MurrayCertificate ::= ... 640b528cefcSMark Murray version [0] Version DEFAULT v1988, 641b528cefcSMark Murray... 642b528cefcSMark Murray 643b528cefcSMark MurrayThe tag is explicit because the default tagging method for 644b528cefcSMark Murraythe ASN.1 "module" in X.509 that defines the Certificate 645b528cefcSMark Murraytype is explicit tagging. 646b528cefcSMark Murray 647b528cefcSMark MurrayBER encoding. Constructed. Contents octets are the BER 648b528cefcSMark Murrayencoding of the underlying value. 649b528cefcSMark Murray 650b528cefcSMark MurrayExample: the BER encoding of the content component of a 651b528cefcSMark MurrayContentInfo value is as follows: 652b528cefcSMark Murray 653b528cefcSMark Murray o identifier octets are a0 654b528cefcSMark Murray 655b528cefcSMark Murray o length octets represent the length of the BER 656b528cefcSMark Murray encoding of the underlying ANY DEFINED BY 657b528cefcSMark Murray contentType value 658b528cefcSMark Murray 659b528cefcSMark Murray o contents octets are the BER encoding of the 660b528cefcSMark Murray underlying ANY DEFINED BY contentType value 661b528cefcSMark Murray 662b528cefcSMark MurrayDER encoding. Constructed. Contents octets are the DER 663b528cefcSMark Murrayencoding of the underlying value. 664b528cefcSMark Murray 665b528cefcSMark Murray 666b528cefcSMark Murray5.3 ANY 667b528cefcSMark Murray 668b528cefcSMark MurrayThe ANY type denotes an arbitrary value of an arbitrary 669b528cefcSMark Murraytype, where the arbitrary type is possibly defined in the 670b528cefcSMark Murrayregistration of an object identifier or associated with an 671b528cefcSMark Murrayinteger index. 672b528cefcSMark Murray 673b528cefcSMark MurrayThe ANY type is used for content of a particular content 674b528cefcSMark Murraytype in PKCS #7's ContentInfo type, for parameters of a 675b528cefcSMark Murrayparticular algorithm in X.509's AlgorithmIdentifier type, 676b528cefcSMark Murrayand for attribute values in X.501's Attribute and 677b528cefcSMark MurrayAttributeValueAssertion types. The Attribute type is used by 678b528cefcSMark MurrayPKCS #6, #7, #8, #9 and #10, and the AttributeValueAssertion 679b528cefcSMark Murraytype is used in X.501 distinguished names. 680b528cefcSMark Murray 681b528cefcSMark MurrayASN.1 notation: 682b528cefcSMark Murray 683b528cefcSMark MurrayANY [DEFINED BY identifier] 684b528cefcSMark Murray 685b528cefcSMark Murraywhere identifier is an optional identifier. 686b528cefcSMark Murray 687b528cefcSMark MurrayIn the ANY form, the actual type is indeterminate. 688b528cefcSMark Murray 689b528cefcSMark MurrayThe ANY DEFINED BY identifier form can only appear in a 690b528cefcSMark Murraycomponent of a SEQUENCE or SET type for which identifier 691b528cefcSMark Murrayidentifies some other component, and that other component 692b528cefcSMark Murrayhas type INTEGER or OBJECT IDENTIFIER (or a type derived 693b528cefcSMark Murrayfrom either of those by tagging). In that form, the actual 694b528cefcSMark Murraytype is determined by the value of the other component, 695b528cefcSMark Murrayeither in the registration of the object identifier value, 696b528cefcSMark Murrayor in a table of integer values. 697b528cefcSMark Murray 698b528cefcSMark MurrayExample: X.509's AlgorithmIdentifier type has a component of 699b528cefcSMark Murraytype ANY: 700b528cefcSMark Murray 701b528cefcSMark MurrayAlgorithmIdentifier ::= SEQUENCE { 702b528cefcSMark Murray algorithm OBJECT IDENTIFIER, 703b528cefcSMark Murray parameters ANY DEFINED BY algorithm OPTIONAL } 704b528cefcSMark Murray 705b528cefcSMark MurrayHere the actual type of the parameter component depends on 706b528cefcSMark Murraythe value of the algorithm component. The actual type would 707b528cefcSMark Murraybe defined in the registration of object identifier values 708b528cefcSMark Murrayfor the algorithm component. 709b528cefcSMark Murray 710b528cefcSMark MurrayBER encoding. Same as the BER encoding of the actual value. 711b528cefcSMark Murray 712b528cefcSMark MurrayExample: The BER encoding of the value of the parameter 713b528cefcSMark Murraycomponent is the BER encoding of the value of the actual 714b528cefcSMark Murraytype as defined in the registration of object identifier 715b528cefcSMark Murrayvalues for the algorithm component. 716b528cefcSMark Murray 717b528cefcSMark MurrayDER encoding. Same as the DER encoding of the actual value. 718b528cefcSMark Murray 719b528cefcSMark Murray 720b528cefcSMark Murray5.4 BIT STRING 721b528cefcSMark Murray 722b528cefcSMark MurrayThe BIT STRING type denotes an arbitrary string of bits 723b528cefcSMark Murray(ones and zeroes). A BIT STRING value can have any length, 724b528cefcSMark Murrayincluding zero. This type is a string type. 725b528cefcSMark Murray 726b528cefcSMark MurrayThe BIT STRING type is used for digital signatures on 727b528cefcSMark Murrayextended certificates in PKCS #6's ExtendedCertificate type, 728b528cefcSMark Murrayfor digital signatures on certificates in X.509's 729b528cefcSMark MurrayCertificate type, and for public keys in certificates in 730b528cefcSMark MurrayX.509's SubjectPublicKeyInfo type. 731b528cefcSMark Murray 732b528cefcSMark MurrayASN.1 notation: 733b528cefcSMark Murray 734b528cefcSMark MurrayBIT STRING 735b528cefcSMark Murray 736b528cefcSMark MurrayExample: X.509's SubjectPublicKeyInfo type has a component 737b528cefcSMark Murrayof type BIT STRING: 738b528cefcSMark Murray 739b528cefcSMark MurraySubjectPublicKeyInfo ::= SEQUENCE { 740b528cefcSMark Murray algorithm AlgorithmIdentifier, 741b528cefcSMark Murray publicKey BIT STRING } 742b528cefcSMark Murray 743b528cefcSMark MurrayBER encoding. Primitive or constructed. In a primitive 744b528cefcSMark Murrayencoding, the first contents octet gives the number of bits 745b528cefcSMark Murrayby which the length of the bit string is less than the next 746b528cefcSMark Murraymultiple of eight (this is called the "number of unused 747b528cefcSMark Murraybits"). The second and following contents octets give the 748b528cefcSMark Murrayvalue of the bit string, converted to an octet string. The 749b528cefcSMark Murrayconversion process is as follows: 750b528cefcSMark Murray 751b528cefcSMark Murray 1. The bit string is padded after the last bit with 752b528cefcSMark Murray zero to seven bits of any value to make the length 753b528cefcSMark Murray of the bit string a multiple of eight. If the 754b528cefcSMark Murray length of the bit string is a multiple of eight 755b528cefcSMark Murray already, no padding is done. 756b528cefcSMark Murray 757b528cefcSMark Murray 2. The padded bit string is divided into octets. The 758b528cefcSMark Murray first eight bits of the padded bit string become 759b528cefcSMark Murray the first octet, bit 8 to bit 1, and so on through 760b528cefcSMark Murray the last eight bits of the padded bit string. 761b528cefcSMark Murray 762b528cefcSMark MurrayIn a constructed encoding, the contents octets give the 763b528cefcSMark Murrayconcatenation of the BER encodings of consecutive substrings 764b528cefcSMark Murrayof the bit string, where each substring except the last has 765b528cefcSMark Murraya length that is a multiple of eight bits. 766b528cefcSMark Murray 767b528cefcSMark MurrayExample: The BER encoding of the BIT STRING value 768b528cefcSMark Murray"011011100101110111" can be any of the following, among 769b528cefcSMark Murrayothers, depending on the choice of padding bits, the form of 770b528cefcSMark Murraylength octets, and whether the encoding is primitive or 771b528cefcSMark Murrayconstructed: 772b528cefcSMark Murray 773b528cefcSMark Murray03 04 06 6e 5d c0 DER encoding 774b528cefcSMark Murray 775b528cefcSMark Murray03 04 06 6e 5d e0 padded with "100000" 776b528cefcSMark Murray 777b528cefcSMark Murray03 81 04 06 6e 5d c0 long form of length octets 778b528cefcSMark Murray 779b528cefcSMark Murray23 09 constructed encoding: "0110111001011101" + "11" 780b528cefcSMark Murray 03 03 00 6e 5d 781b528cefcSMark Murray 03 02 06 c0 782b528cefcSMark Murray 783b528cefcSMark MurrayDER encoding. Primitive. The contents octects are as for a 784b528cefcSMark Murrayprimitive BER encoding, except that the bit string is padded 785b528cefcSMark Murraywith zero-valued bits. 786b528cefcSMark Murray 787b528cefcSMark MurrayExample: The DER encoding of the BIT STRING value 788b528cefcSMark Murray"011011100101110111" is 789b528cefcSMark Murray 790b528cefcSMark Murray03 04 06 6e 5d c0 791b528cefcSMark Murray 792b528cefcSMark Murray 793b528cefcSMark Murray5.5 CHOICE 794b528cefcSMark Murray 795b528cefcSMark MurrayThe CHOICE type denotes a union of one or more alternatives. 796b528cefcSMark Murray 797b528cefcSMark MurrayThe CHOICE type is used to represent the union of an 798b528cefcSMark Murrayextended certificate and an X.509 certificate in PKCS #7's 799b528cefcSMark MurrayExtendedCertificateOrCertificate type. 800b528cefcSMark Murray 801b528cefcSMark MurrayASN.1 notation: 802b528cefcSMark Murray 803b528cefcSMark MurrayCHOICE { 804b528cefcSMark Murray [identifier1] Type1, 805b528cefcSMark Murray ..., 806b528cefcSMark Murray [identifiern] Typen } 807b528cefcSMark Murray 808b528cefcSMark Murraywhere identifier1 , ..., identifiern are optional, distinct 809b528cefcSMark Murrayidentifiers for the alternatives, and Type1, ..., Typen are 810b528cefcSMark Murraythe types of the alternatives. The identifiers are primarily 811b528cefcSMark Murrayfor documentation; they do not affect values of the type or 812b528cefcSMark Murraytheir encodings in any way. 813b528cefcSMark Murray 814b528cefcSMark MurrayThe types must have distinct tags. This requirement is 815b528cefcSMark Murraytypically satisfied with explicit or implicit tagging on 816b528cefcSMark Murraysome of the alternatives. 817b528cefcSMark Murray 818b528cefcSMark MurrayExample: PKCS #7's ExtendedCertificateOrCertificate type is 819b528cefcSMark Murraya CHOICE type: 820b528cefcSMark Murray 821b528cefcSMark MurrayExtendedCertificateOrCertificate ::= CHOICE { 822b528cefcSMark Murray certificate Certificate, -- X.509 823b528cefcSMark Murray extendedCertificate [0] IMPLICIT ExtendedCertificate 824b528cefcSMark Murray} 825b528cefcSMark Murray 826b528cefcSMark MurrayHere the identifiers for the alternatives are certificate 827b528cefcSMark Murrayand extendedCertificate, and the types of the alternatives 828b528cefcSMark Murrayare Certificate and [0] IMPLICIT ExtendedCertificate. 829b528cefcSMark Murray 830b528cefcSMark MurrayBER encoding. Same as the BER encoding of the chosen 831b528cefcSMark Murrayalternative. The fact that the alternatives have distinct 832b528cefcSMark Murraytags makes it possible to distinguish between their BER 833b528cefcSMark Murrayencodings. 834b528cefcSMark Murray 835b528cefcSMark MurrayExample: The identifier octets for the BER encoding are 30 836b528cefcSMark Murrayif the chosen alternative is certificate, and a0 if the 837b528cefcSMark Murraychosen alternative is extendedCertificate. 838b528cefcSMark Murray 839b528cefcSMark MurrayDER encoding. Same as the DER encoding of the chosen 840b528cefcSMark Murrayalternative. 841b528cefcSMark Murray 842b528cefcSMark Murray 843b528cefcSMark Murray5.6 IA5String 844b528cefcSMark Murray 845b528cefcSMark MurrayThe IA5String type denotes an arbtrary string of IA5 846b528cefcSMark Murraycharacters. IA5 stands for International Alphabet 5, which 847b528cefcSMark Murrayis the same as ASCII. The character set includes non- 848b528cefcSMark Murrayprinting control characters. An IA5String value can have any 849b528cefcSMark Murraylength, including zero. This type is a string type. 850b528cefcSMark Murray 851b528cefcSMark MurrayThe IA5String type is used in PKCS #9's electronic-mail 852b528cefcSMark Murrayaddress, unstructured-name, and unstructured-address 853b528cefcSMark Murrayattributes. 854b528cefcSMark Murray 855b528cefcSMark MurrayASN.1 notation: 856b528cefcSMark Murray 857b528cefcSMark MurrayIA5String 858b528cefcSMark Murray 859b528cefcSMark MurrayBER encoding. Primitive or constructed. In a primitive 860b528cefcSMark Murrayencoding, the contents octets give the characters in the IA5 861b528cefcSMark Murraystring, encoded in ASCII. In a constructed encoding, the 862b528cefcSMark Murraycontents octets give the concatenation of the BER encodings 863b528cefcSMark Murrayof consecutive substrings of the IA5 string. 864b528cefcSMark Murray 865b528cefcSMark MurrayExample: The BER encoding of the IA5String value 866b528cefcSMark Murray"test1@rsa.com" can be any of the following, among others, 867b528cefcSMark Murraydepending on the form of length octets and whether the 868b528cefcSMark Murrayencoding is primitive or constructed: 869b528cefcSMark Murray 870b528cefcSMark Murray16 0d 74 65 73 74 31 40 72 73 61 2e 63 6f 6d DER encoding 871b528cefcSMark Murray 872b528cefcSMark Murray16 81 0d long form of length octets 873b528cefcSMark Murray 74 65 73 74 31 40 72 73 61 2e 63 6f 6d 874b528cefcSMark Murray 875b528cefcSMark Murray36 13 constructed encoding: "test1" + "@" + "rsa.com" 876b528cefcSMark Murray 16 05 74 65 73 74 31 877b528cefcSMark Murray 16 01 40 878b528cefcSMark Murray 16 07 72 73 61 2e 63 6f 6d 879b528cefcSMark Murray 880b528cefcSMark MurrayDER encoding. Primitive. Contents octets are as for a 881b528cefcSMark Murrayprimitive BER encoding. 882b528cefcSMark Murray 883b528cefcSMark MurrayExample: The DER encoding of the IA5String value 884b528cefcSMark Murray"test1@rsa.com" is 885b528cefcSMark Murray 886b528cefcSMark Murray16 0d 74 65 73 74 31 40 72 73 61 2e 63 6f 6d 887b528cefcSMark Murray 888b528cefcSMark Murray 889b528cefcSMark Murray5.7 INTEGER 890b528cefcSMark Murray 891b528cefcSMark MurrayThe INTEGER type denotes an arbitrary integer. INTEGER 892b528cefcSMark Murrayvalues can be positive, negative, or zero, and can have any 893b528cefcSMark Murraymagnitude. 894b528cefcSMark Murray 895b528cefcSMark MurrayThe INTEGER type is used for version numbers throughout 896b528cefcSMark MurrayPKCS, cryptographic values such as modulus, exponent, and 897b528cefcSMark Murrayprimes in PKCS #1's RSAPublicKey and RSAPrivateKey types and 898b528cefcSMark MurrayPKCS #3's DHParameter type, a message-digest iteration count 899b528cefcSMark Murrayin PKCS #5's PBEParameter type, and version numbers and 900b528cefcSMark Murrayserial numbers in X.509's Certificate type. 901b528cefcSMark Murray 902b528cefcSMark MurrayASN.1 notation: 903b528cefcSMark Murray 904b528cefcSMark MurrayINTEGER [{ identifier1(value1) ... identifiern(valuen) }] 905b528cefcSMark Murray 906b528cefcSMark Murraywhere identifier1, ..., identifiern are optional distinct 907b528cefcSMark Murrayidentifiers and value1, ..., valuen are optional integer 908b528cefcSMark Murrayvalues. The identifiers, when present, are associated with 909b528cefcSMark Murrayvalues of the type. 910b528cefcSMark Murray 911b528cefcSMark MurrayExample: X.509's Version type is an INTEGER type with 912b528cefcSMark Murrayidentified values: 913b528cefcSMark Murray 914b528cefcSMark MurrayVersion ::= INTEGER { v1988(0) } 915b528cefcSMark Murray 916b528cefcSMark MurrayThe identifier v1988 is associated with the value 0. X.509's 917b528cefcSMark MurrayCertificate type uses the identifier v1988 to give a default 918b528cefcSMark Murrayvalue of 0 for the version component: 919b528cefcSMark Murray 920b528cefcSMark MurrayCertificate ::= ... 921b528cefcSMark Murray version Version DEFAULT v1988, 922b528cefcSMark Murray... 923b528cefcSMark Murray 924b528cefcSMark MurrayBER encoding. Primitive. Contents octets give the value of 925b528cefcSMark Murraythe integer, base 256, in two's complement form, most 926b528cefcSMark Murraysignificant digit first, with the minimum number of octets. 927b528cefcSMark MurrayThe value 0 is encoded as a single 00 octet. 928b528cefcSMark Murray 929b528cefcSMark MurraySome example BER encodings (which also happen to be DER 930b528cefcSMark Murrayencodings) are given in Table 3. 931b528cefcSMark Murray 932b528cefcSMark Murray Integer BER encoding 933b528cefcSMark Murray value 934b528cefcSMark Murray 0 02 01 00 935b528cefcSMark Murray 127 02 01 7F 936b528cefcSMark Murray 128 02 02 00 80 937b528cefcSMark Murray 256 02 02 01 00 938b528cefcSMark Murray -128 02 01 80 939b528cefcSMark Murray -129 02 02 FF 7F 940b528cefcSMark Murray 941b528cefcSMark Murray Table 3. Example BER encodings of INTEGER values. 942b528cefcSMark Murray 943b528cefcSMark MurrayDER encoding. Primitive. Contents octets are as for a 944b528cefcSMark Murrayprimitive BER encoding. 945b528cefcSMark Murray 946b528cefcSMark Murray 947b528cefcSMark Murray5.8 NULL 948b528cefcSMark Murray 949b528cefcSMark MurrayThe NULL type denotes a null value. 950b528cefcSMark Murray 951b528cefcSMark MurrayThe NULL type is used for algorithm parameters in several 952b528cefcSMark Murrayplaces in PKCS. 953b528cefcSMark Murray 954b528cefcSMark MurrayASN.1 notation: 955b528cefcSMark Murray 956b528cefcSMark MurrayNULL 957b528cefcSMark Murray 958b528cefcSMark MurrayBER encoding. Primitive. Contents octets are empty. 959b528cefcSMark Murray 960b528cefcSMark MurrayExample: The BER encoding of a NULL value can be either of 961b528cefcSMark Murraythe following, as well as others, depending on the form of 962b528cefcSMark Murraythe length octets: 963b528cefcSMark Murray 964b528cefcSMark Murray05 00 965b528cefcSMark Murray 966b528cefcSMark Murray05 81 00 967b528cefcSMark Murray 968b528cefcSMark MurrayDER encoding. Primitive. Contents octets are empty; the DER 969b528cefcSMark Murrayencoding of a NULL value is always 05 00. 970b528cefcSMark Murray 971b528cefcSMark Murray 972b528cefcSMark Murray5.9 OBJECT IDENTIFIER 973b528cefcSMark Murray 974b528cefcSMark MurrayThe OBJECT IDENTIFIER type denotes an object identifier, a 975b528cefcSMark Murraysequence of integer components that identifies an object 976b528cefcSMark Murraysuch as an algorithm, an attribute type, or perhaps a 977b528cefcSMark Murrayregistration authority that defines other object 978b528cefcSMark Murrayidentifiers. An OBJECT IDENTIFIER value can have any number 979b528cefcSMark Murrayof components, and components can generally have any 980b528cefcSMark Murraynonnegative value. This type is a non-string type. 981b528cefcSMark Murray 982b528cefcSMark MurrayOBJECT IDENTIFIER values are given meanings by registration 983b528cefcSMark Murrayauthorities. Each registration authority is responsible for 984b528cefcSMark Murrayall sequences of components beginning with a given sequence. 985b528cefcSMark MurrayA registration authority typically delegates responsibility 986b528cefcSMark Murrayfor subsets of the sequences in its domain to other 987b528cefcSMark Murrayregistration authorities, or for particular types of object. 988b528cefcSMark MurrayThere are always at least two components. 989b528cefcSMark Murray 990b528cefcSMark MurrayThe OBJECT IDENTIFIER type is used to identify content in 991b528cefcSMark MurrayPKCS #7's ContentInfo type, to identify algorithms in 992b528cefcSMark MurrayX.509's AlgorithmIdentifier type, and to identify attributes 993b528cefcSMark Murrayin X.501's Attribute and AttributeValueAssertion types. The 994b528cefcSMark MurrayAttribute type is used by PKCS #6, #7, #8, #9, and #10, and 995b528cefcSMark Murraythe AttributeValueAssertion type is used in X.501 996b528cefcSMark Murraydistinguished names. OBJECT IDENTIFIER values are defined 997b528cefcSMark Murraythroughout PKCS. 998b528cefcSMark Murray 999b528cefcSMark MurrayASN.1 notation: 1000b528cefcSMark Murray 1001b528cefcSMark MurrayOBJECT IDENTIFIER 1002b528cefcSMark Murray 1003b528cefcSMark MurrayThe ASN.1 notation for values of the OBJECT IDENTIFIER type 1004b528cefcSMark Murrayis 1005b528cefcSMark Murray 1006b528cefcSMark Murray{ [identifier] component1 ... componentn } 1007b528cefcSMark Murray 1008b528cefcSMark Murraycomponenti = identifieri | identifieri (valuei) | valuei 1009b528cefcSMark Murray 1010b528cefcSMark Murraywhere identifier, identifier1, ..., identifiern are 1011b528cefcSMark Murrayidentifiers, and value1, ..., valuen are optional integer 1012b528cefcSMark Murrayvalues. 1013b528cefcSMark Murray 1014b528cefcSMark MurrayThe form without identifier is the "complete" value with all 1015b528cefcSMark Murrayits components; the form with identifier abbreviates the 1016b528cefcSMark Murraybeginning components with another object identifier value. 1017b528cefcSMark MurrayThe identifiers identifier1, ..., identifiern are intended 1018b528cefcSMark Murrayprimarily for documentation, but they must correspond to the 1019b528cefcSMark Murrayinteger value when both are present. These identifiers can 1020b528cefcSMark Murrayappear without integer values only if they are among a small 1021b528cefcSMark Murrayset of identifiers defined in X.208. 1022b528cefcSMark Murray 1023b528cefcSMark MurrayExample: The following values both refer to the object 1024b528cefcSMark Murrayidentifier assigned to RSA Data Security, Inc.: 1025b528cefcSMark Murray 1026b528cefcSMark Murray{ iso(1) member-body(2) 840 113549 } 1027b528cefcSMark Murray{ 1 2 840 113549 } 1028b528cefcSMark Murray 1029b528cefcSMark Murray(In this example, which gives ASN.1 value notation, the 1030b528cefcSMark Murrayobject identifier values are decimal, not hexadecimal.) 1031b528cefcSMark MurrayTable 4 gives some other object identifier values and their 1032b528cefcSMark Murraymeanings. 1033b528cefcSMark Murray 1034b528cefcSMark Murray Object identifier value Meaning 1035b528cefcSMark Murray { 1 2 } ISO member bodies 1036b528cefcSMark Murray { 1 2 840 } US (ANSI) 1037b528cefcSMark Murray { 1 2 840 113549 } RSA Data Security, Inc. 1038b528cefcSMark Murray { 1 2 840 113549 1 } RSA Data Security, Inc. PKCS 1039b528cefcSMark Murray { 2 5 } directory services (X.500) 1040b528cefcSMark Murray { 2 5 8 } directory services-algorithms 1041b528cefcSMark Murray 1042b528cefcSMark Murray Table 4. Some object identifier values and their meanings. 1043b528cefcSMark Murray 1044b528cefcSMark MurrayBER encoding. Primitive. Contents octets are as follows, 1045b528cefcSMark Murraywhere value1, ..., valuen denote the integer values of the 1046b528cefcSMark Murraycomponents in the complete object identifier: 1047b528cefcSMark Murray 1048b528cefcSMark Murray 1. The first octet has value 40 * value1 + value2. 1049b528cefcSMark Murray (This is unambiguous, since value1 is limited to 1050b528cefcSMark Murray values 0, 1, and 2; value2 is limited to the range 1051b528cefcSMark Murray 0 to 39 when value1 is 0 or 1; and, according to 1052b528cefcSMark Murray X.208, n is always at least 2.) 1053b528cefcSMark Murray 1054b528cefcSMark Murray 2. The following octets, if any, encode value3, ..., 1055b528cefcSMark Murray valuen. Each value is encoded base 128, most 1056b528cefcSMark Murray significant digit first, with as few digits as 1057b528cefcSMark Murray possible, and the most significant bit of each 1058b528cefcSMark Murray octet except the last in the value's encoding set 1059b528cefcSMark Murray to "1." 1060b528cefcSMark Murray 1061b528cefcSMark MurrayExample: The first octet of the BER encoding of RSA Data 1062b528cefcSMark MurraySecurity, Inc.'s object identifier is 40 * 1 + 2 = 42 = 1063b528cefcSMark Murray2a16. The encoding of 840 = 6 * 128 + 4816 is 86 48 and the 1064b528cefcSMark Murrayencoding of 113549 = 6 * 1282 + 7716 * 128 + d16 is 86 f7 1065b528cefcSMark Murray0d. This leads to the following BER encoding: 1066b528cefcSMark Murray 1067b528cefcSMark Murray06 06 2a 86 48 86 f7 0d 1068b528cefcSMark Murray 1069b528cefcSMark MurrayDER encoding. Primitive. Contents octets are as for a 1070b528cefcSMark Murrayprimitive BER encoding. 1071b528cefcSMark Murray 1072b528cefcSMark Murray 1073b528cefcSMark Murray5.10 OCTET STRING 1074b528cefcSMark Murray 1075b528cefcSMark MurrayThe OCTET STRING type denotes an arbitrary string of octets 1076b528cefcSMark Murray(eight-bit values). An OCTET STRING value can have any 1077b528cefcSMark Murraylength, including zero. This type is a string type. 1078b528cefcSMark Murray 1079b528cefcSMark MurrayThe OCTET STRING type is used for salt values in PKCS #5's 1080b528cefcSMark MurrayPBEParameter type, for message digests, encrypted message 1081b528cefcSMark Murraydigests, and encrypted content in PKCS #7, and for private 1082b528cefcSMark Murraykeys and encrypted private keys in PKCS #8. 1083b528cefcSMark Murray 1084b528cefcSMark MurrayASN.1 notation: 1085b528cefcSMark Murray 1086b528cefcSMark MurrayOCTET STRING [SIZE ({size | size1..size2})] 1087b528cefcSMark Murray 1088b528cefcSMark Murraywhere size, size1, and size2 are optional size constraints. 1089b528cefcSMark MurrayIn the OCTET STRING SIZE (size) form, the octet string must 1090b528cefcSMark Murrayhave size octets. In the OCTET STRING SIZE (size1..size2) 1091b528cefcSMark Murrayform, the octet string must have between size1 and size2 1092b528cefcSMark Murrayoctets. In the OCTET STRING form, the octet string can have 1093b528cefcSMark Murrayany size. 1094b528cefcSMark Murray 1095b528cefcSMark MurrayExample: PKCS #5's PBEParameter type has a component of type 1096b528cefcSMark MurrayOCTET STRING: 1097b528cefcSMark Murray 1098b528cefcSMark MurrayPBEParameter ::= SEQUENCE { 1099b528cefcSMark Murray salt OCTET STRING SIZE(8), 1100b528cefcSMark Murray iterationCount INTEGER } 1101b528cefcSMark Murray 1102b528cefcSMark MurrayHere the size of the salt component is always eight octets. 1103b528cefcSMark Murray 1104b528cefcSMark MurrayBER encoding. Primitive or constructed. In a primitive 1105b528cefcSMark Murrayencoding, the contents octets give the value of the octet 1106b528cefcSMark Murraystring, first octet to last octet. In a constructed 1107b528cefcSMark Murrayencoding, the contents octets give the concatenation of the 1108b528cefcSMark MurrayBER encodings of substrings of the OCTET STRING value. 1109b528cefcSMark Murray 1110b528cefcSMark MurrayExample: The BER encoding of the OCTET STRING value 01 23 45 1111b528cefcSMark Murray67 89 ab cd ef can be any of the following, among others, 1112b528cefcSMark Murraydepending on the form of length octets and whether the 1113b528cefcSMark Murrayencoding is primitive or constructed: 1114b528cefcSMark Murray 1115b528cefcSMark Murray04 08 01 23 45 67 89 ab cd ef DER encoding 1116b528cefcSMark Murray 1117b528cefcSMark Murray04 81 08 01 23 45 67 89 ab cd ef long form of length octets 1118b528cefcSMark Murray 1119b528cefcSMark Murray24 0c constructed encoding: 01 ... 67 + 89 ... ef 1120b528cefcSMark Murray 04 04 01 23 45 67 1121b528cefcSMark Murray 04 04 89 ab cd ef 1122b528cefcSMark Murray 1123b528cefcSMark MurrayDER encoding. Primitive. Contents octets are as for a 1124b528cefcSMark Murrayprimitive BER encoding. 1125b528cefcSMark Murray 1126b528cefcSMark MurrayExample: The BER encoding of the OCTET STRING value 01 23 45 1127b528cefcSMark Murray67 89 ab cd ef is 1128b528cefcSMark Murray 1129b528cefcSMark Murray04 08 01 23 45 67 89 ab cd ef 1130b528cefcSMark Murray 1131b528cefcSMark Murray 1132b528cefcSMark Murray5.11 PrintableString 1133b528cefcSMark Murray 1134b528cefcSMark MurrayThe PrintableString type denotes an arbitrary string of 1135b528cefcSMark Murrayprintable characters from the following character set: 1136b528cefcSMark Murray 1137b528cefcSMark Murray A, B, ..., Z 1138b528cefcSMark Murray a, b, ..., z 1139b528cefcSMark Murray 0, 1, ..., 9 1140b528cefcSMark Murray (space) ' ( ) + , - . / : = ? 1141b528cefcSMark Murray 1142b528cefcSMark MurrayThis type is a string type. 1143b528cefcSMark Murray 1144b528cefcSMark MurrayThe PrintableString type is used in PKCS #9's challenge- 1145b528cefcSMark Murraypassword and unstructuerd-address attributes, and in several 1146b528cefcSMark MurrayX.521 distinguished names attributes. 1147b528cefcSMark Murray 1148b528cefcSMark MurrayASN.1 notation: 1149b528cefcSMark Murray 1150b528cefcSMark MurrayPrintableString 1151b528cefcSMark Murray 1152b528cefcSMark MurrayBER encoding. Primitive or constructed. In a primitive 1153b528cefcSMark Murrayencoding, the contents octets give the characters in the 1154b528cefcSMark Murrayprintable string, encoded in ASCII. In a constructed 1155b528cefcSMark Murrayencoding, the contents octets give the concatenation of the 1156b528cefcSMark MurrayBER encodings of consecutive substrings of the string. 1157b528cefcSMark Murray 1158b528cefcSMark MurrayExample: The BER encoding of the PrintableString value "Test 1159b528cefcSMark MurrayUser 1" can be any of the following, among others, depending 1160b528cefcSMark Murrayon the form of length octets and whether the encoding is 1161b528cefcSMark Murrayprimitive or constructed: 1162b528cefcSMark Murray 1163b528cefcSMark Murray13 0b 54 65 73 74 20 55 73 65 72 20 31 DER encoding 1164b528cefcSMark Murray 1165b528cefcSMark Murray13 81 0b long form of length octets 1166b528cefcSMark Murray 54 65 73 74 20 55 73 65 72 20 31 1167b528cefcSMark Murray 1168b528cefcSMark Murray33 0f constructed encoding: "Test " + "User 1" 1169b528cefcSMark Murray 13 05 54 65 73 74 20 1170b528cefcSMark Murray 13 06 55 73 65 72 20 31 1171b528cefcSMark Murray 1172b528cefcSMark MurrayDER encoding. Primitive. Contents octets are as for a 1173b528cefcSMark Murrayprimitive BER encoding. 1174b528cefcSMark Murray 1175b528cefcSMark MurrayExample: The DER encoding of the PrintableString value "Test 1176b528cefcSMark MurrayUser 1" is 1177b528cefcSMark Murray 1178b528cefcSMark Murray13 0b 54 65 73 74 20 55 73 65 72 20 31 1179b528cefcSMark Murray 1180b528cefcSMark Murray 1181b528cefcSMark Murray5.12 SEQUENCE 1182b528cefcSMark Murray 1183b528cefcSMark MurrayThe SEQUENCE type denotes an ordered collection of one or 1184b528cefcSMark Murraymore types. 1185b528cefcSMark Murray 1186b528cefcSMark MurrayThe SEQUENCE type is used throughout PKCS and related 1187b528cefcSMark Murraystandards. 1188b528cefcSMark Murray 1189b528cefcSMark MurrayASN.1 notation: 1190b528cefcSMark Murray 1191b528cefcSMark MurraySEQUENCE { 1192b528cefcSMark Murray [identifier1] Type1 [{OPTIONAL | DEFAULT value1}], 1193b528cefcSMark Murray ..., 1194b528cefcSMark Murray [identifiern] Typen [{OPTIONAL | DEFAULT valuen}]} 1195b528cefcSMark Murray 1196b528cefcSMark Murraywhere identifier1 , ..., identifiern are optional, distinct 1197b528cefcSMark Murrayidentifiers for the components, Type1, ..., Typen are the 1198b528cefcSMark Murraytypes of the components, and value1, ..., valuen are optional 1199b528cefcSMark Murraydefault values for the components. The identifiers are 1200b528cefcSMark Murrayprimarily for documentation; they do not affect values of 1201b528cefcSMark Murraythe type or their encodings in any way. 1202b528cefcSMark Murray 1203b528cefcSMark MurrayThe OPTIONAL qualifier indicates that the value of a 1204b528cefcSMark Murraycomponent is optional and need not be present in the 1205b528cefcSMark Murraysequence. The DEFAULT qualifier also indicates that the 1206b528cefcSMark Murrayvalue of a component is optional, and assigns a default 1207b528cefcSMark Murrayvalue to the component when the component is absent. 1208b528cefcSMark Murray 1209b528cefcSMark MurrayThe types of any consecutive series of components with the 1210b528cefcSMark MurrayOPTIONAL or DEFAULT qualifier, as well as of any component 1211b528cefcSMark Murrayimmediately following that series, must have distinct tags. 1212b528cefcSMark MurrayThis requirement is typically satisfied with explicit or 1213b528cefcSMark Murrayimplicit tagging on some of the components. 1214b528cefcSMark Murray 1215b528cefcSMark MurrayExample: X.509's Validity type is a SEQUENCE type with two 1216b528cefcSMark Murraycomponents: 1217b528cefcSMark Murray 1218b528cefcSMark MurrayValidity ::= SEQUENCE { 1219b528cefcSMark Murray start UTCTime, 1220b528cefcSMark Murray end UTCTime } 1221b528cefcSMark Murray 1222b528cefcSMark MurrayHere the identifiers for the components are start and end, 1223b528cefcSMark Murrayand the types of the components are both UTCTime. 1224b528cefcSMark Murray 1225b528cefcSMark MurrayBER encoding. Constructed. Contents octets are the 1226b528cefcSMark Murrayconcatenation of the BER encodings of the values of the 1227b528cefcSMark Murraycomponents of the sequence, in order of definition, with the 1228b528cefcSMark Murrayfollowing rules for components with the OPTIONAL and DEFAULT 1229b528cefcSMark Murrayqualifiers: 1230b528cefcSMark Murray 1231b528cefcSMark Murray o if the value of a component with the OPTIONAL or 1232b528cefcSMark Murray DEFAULT qualifier is absent from the sequence, 1233b528cefcSMark Murray then the encoding of that component is not 1234b528cefcSMark Murray included in the contents octets 1235b528cefcSMark Murray 1236b528cefcSMark Murray o if the value of a component with the DEFAULT 1237b528cefcSMark Murray qualifier is the default value, then the encoding 1238b528cefcSMark Murray of that component may or may not be included in 1239b528cefcSMark Murray the contents octets 1240b528cefcSMark Murray 1241b528cefcSMark MurrayDER encoding. Constructed. Contents octets are the same as 1242b528cefcSMark Murraythe BER encoding, except that if the value of a component 1243b528cefcSMark Murraywith the DEFAULT qualifier is the default value, the 1244b528cefcSMark Murrayencoding of that component is not included in the contents 1245b528cefcSMark Murrayoctets. 1246b528cefcSMark Murray 1247b528cefcSMark Murray 1248b528cefcSMark Murray5.13 SEQUENCE OF 1249b528cefcSMark Murray 1250b528cefcSMark MurrayThe SEQUENCE OF type denotes an ordered collection of zero 1251b528cefcSMark Murrayor more occurrences of a given type. 1252b528cefcSMark Murray 1253b528cefcSMark MurrayThe SEQUENCE OF type is used in X.501 distinguished names. 1254b528cefcSMark Murray 1255b528cefcSMark MurrayASN.1 notation: 1256b528cefcSMark Murray 1257b528cefcSMark MurraySEQUENCE OF Type 1258b528cefcSMark Murray 1259b528cefcSMark Murraywhere Type is a type. 1260b528cefcSMark Murray 1261b528cefcSMark MurrayExample: X.501's RDNSequence type consists of zero or more 1262b528cefcSMark Murrayoccurences of the RelativeDistinguishedName type, most 1263b528cefcSMark Murraysignificant occurrence first: 1264b528cefcSMark Murray 1265b528cefcSMark MurrayRDNSequence ::= SEQUENCE OF RelativeDistinguishedName 1266b528cefcSMark Murray 1267b528cefcSMark MurrayBER encoding. Constructed. Contents octets are the 1268b528cefcSMark Murrayconcatenation of the BER encodings of the values of the 1269b528cefcSMark Murrayoccurrences in the collection, in order of occurence. 1270b528cefcSMark Murray 1271b528cefcSMark MurrayDER encoding. Constructed. Contents octets are the 1272b528cefcSMark Murrayconcatenation of the DER encodings of the values of the 1273b528cefcSMark Murrayoccurrences in the collection, in order of occurence. 1274b528cefcSMark Murray 1275b528cefcSMark Murray 1276b528cefcSMark Murray5.14 SET 1277b528cefcSMark Murray 1278b528cefcSMark MurrayThe SET type denotes an unordered collection of one or more 1279b528cefcSMark Murraytypes. 1280b528cefcSMark Murray 1281b528cefcSMark MurrayThe SET type is not used in PKCS. 1282b528cefcSMark Murray 1283b528cefcSMark MurrayASN.1 notation: 1284b528cefcSMark Murray 1285b528cefcSMark MurraySET { 1286b528cefcSMark Murray [identifier1] Type1 [{OPTIONAL | DEFAULT value1}], 1287b528cefcSMark Murray ..., 1288b528cefcSMark Murray [identifiern] Typen [{OPTIONAL | DEFAULT valuen}]} 1289b528cefcSMark Murray 1290b528cefcSMark Murraywhere identifier1, ..., identifiern are optional, distinct 1291b528cefcSMark Murrayidentifiers for the components, Type1, ..., Typen are the 1292b528cefcSMark Murraytypes of the components, and value1, ..., valuen are 1293b528cefcSMark Murrayoptional default values for the components. The identifiers 1294b528cefcSMark Murrayare primarily for documentation; they do not affect values 1295b528cefcSMark Murrayof the type or their encodings in any way. 1296b528cefcSMark Murray 1297b528cefcSMark MurrayThe OPTIONAL qualifier indicates that the value of a 1298b528cefcSMark Murraycomponent is optional and need not be present in the set. 1299b528cefcSMark MurrayThe DEFAULT qualifier also indicates that the value of a 1300b528cefcSMark Murraycomponent is optional, and assigns a default value to the 1301b528cefcSMark Murraycomponent when the component is absent. 1302b528cefcSMark Murray 1303b528cefcSMark MurrayThe types must have distinct tags. This requirement is 1304b528cefcSMark Murraytypically satisfied with explicit or implicit tagging on 1305b528cefcSMark Murraysome of the components. 1306b528cefcSMark Murray 1307b528cefcSMark MurrayBER encoding. Constructed. Contents octets are the 1308b528cefcSMark Murrayconcatenation of the BER encodings of the values of the 1309b528cefcSMark Murraycomponents of the set, in any order, with the following 1310b528cefcSMark Murrayrules for components with the OPTIONAL and DEFAULT 1311b528cefcSMark Murrayqualifiers: 1312b528cefcSMark Murray 1313b528cefcSMark Murray o if the value of a component with the OPTIONAL or 1314b528cefcSMark Murray DEFAULT qualifier is absent from the set, then the 1315b528cefcSMark Murray encoding of that component is not included in the 1316b528cefcSMark Murray contents octets 1317b528cefcSMark Murray 1318b528cefcSMark Murray o if the value of a component with the DEFAULT 1319b528cefcSMark Murray qualifier is the default value, then the encoding 1320b528cefcSMark Murray of that component may or may not be included in 1321b528cefcSMark Murray the contents octets 1322b528cefcSMark Murray 1323b528cefcSMark MurrayDER encoding. Constructed. Contents octets are the same as 1324b528cefcSMark Murrayfor the BER encoding, except that: 1325b528cefcSMark Murray 1326b528cefcSMark Murray 1. If the value of a component with the DEFAULT 1327b528cefcSMark Murray qualifier is the default value, the encoding of 1328b528cefcSMark Murray that component is not included. 1329b528cefcSMark Murray 1330b528cefcSMark Murray 2. There is an order to the components, namely 1331b528cefcSMark Murray ascending order by tag. 1332b528cefcSMark Murray 1333b528cefcSMark Murray 1334b528cefcSMark Murray5.15 SET OF 1335b528cefcSMark Murray 1336b528cefcSMark MurrayThe SET OF type denotes an unordered collection of zero or 1337b528cefcSMark Murraymore occurrences of a given type. 1338b528cefcSMark Murray 1339b528cefcSMark MurrayThe SET OF type is used for sets of attributes in PKCS #6, 1340b528cefcSMark Murray#7, #8, #9 and #10, for sets of message-digest algorithm 1341b528cefcSMark Murrayidentifiers, signer information, and recipient information 1342b528cefcSMark Murrayin PKCS #7, and in X.501 distinguished names. 1343b528cefcSMark Murray 1344b528cefcSMark MurrayASN.1 notation: 1345b528cefcSMark Murray 1346b528cefcSMark MurraySET OF Type 1347b528cefcSMark Murray 1348b528cefcSMark Murraywhere Type is a type. 1349b528cefcSMark Murray 1350b528cefcSMark MurrayExample: X.501's RelativeDistinguishedName type consists of 1351b528cefcSMark Murrayzero or more occurrences of the AttributeValueAssertion 1352b528cefcSMark Murraytype, where the order is unimportant: 1353b528cefcSMark Murray 1354b528cefcSMark MurrayRelativeDistinguishedName ::= 1355b528cefcSMark Murray SET OF AttributeValueAssertion 1356b528cefcSMark Murray 1357b528cefcSMark MurrayBER encoding. Constructed. Contents octets are the 1358b528cefcSMark Murrayconcatenation of the BER encodings of the values of the 1359b528cefcSMark Murrayoccurrences in the collection, in any order. 1360b528cefcSMark Murray 1361b528cefcSMark MurrayDER encoding. Constructed. Contents octets are the same as 1362b528cefcSMark Murrayfor the BER encoding, except that there is an order, namely 1363b528cefcSMark Murrayascending lexicographic order of BER encoding. Lexicographic 1364b528cefcSMark Murraycomparison of two different BER encodings is done as 1365b528cefcSMark Murrayfollows: Logically pad the shorter BER encoding after the 1366b528cefcSMark Murraylast octet with dummy octets that are smaller in value than 1367b528cefcSMark Murrayany normal octet. Scan the BER encodings from left to right 1368b528cefcSMark Murrayuntil a difference is found. The smaller-valued BER encoding 1369b528cefcSMark Murrayis the one with the smaller-valued octet at the point of 1370b528cefcSMark Murraydifference. 1371b528cefcSMark Murray 1372b528cefcSMark Murray 1373b528cefcSMark Murray5.16 T61String 1374b528cefcSMark Murray 1375b528cefcSMark MurrayThe T61String type denotes an arbtrary string of T.61 1376b528cefcSMark Murraycharacters. T.61 is an eight-bit extension to the ASCII 1377b528cefcSMark Murraycharacter set. Special "escape" sequences specify the 1378b528cefcSMark Murrayinterpretation of subsequent character values as, for 1379b528cefcSMark Murrayexample, Japanese; the initial interpretation is Latin. The 1380b528cefcSMark Murraycharacter set includes non-printing control characters. The 1381b528cefcSMark MurrayT61String type allows only the Latin and Japanese character 1382b528cefcSMark Murrayinterepretations, and implementors' agreements for directory 1383b528cefcSMark Murraynames exclude control characters [NIST92]. A T61String value 1384b528cefcSMark Murraycan have any length, including zero. This type is a string 1385b528cefcSMark Murraytype. 1386b528cefcSMark Murray 1387b528cefcSMark MurrayThe T61String type is used in PKCS #9's unstructured-address 1388b528cefcSMark Murrayand challenge-password attributes, and in several X.521 1389b528cefcSMark Murrayattributes. 1390b528cefcSMark Murray 1391b528cefcSMark MurrayASN.1 notation: 1392b528cefcSMark Murray 1393b528cefcSMark MurrayT61String 1394b528cefcSMark Murray 1395b528cefcSMark MurrayBER encoding. Primitive or constructed. In a primitive 1396b528cefcSMark Murrayencoding, the contents octets give the characters in the 1397b528cefcSMark MurrayT.61 string, encoded in ASCII. In a constructed encoding, 1398b528cefcSMark Murraythe contents octets give the concatenation of the BER 1399b528cefcSMark Murrayencodings of consecutive substrings of the T.61 string. 1400b528cefcSMark Murray 1401b528cefcSMark MurrayExample: The BER encoding of the T61String value "cl'es 1402b528cefcSMark Murraypubliques" (French for "public keys") can be any of the 1403b528cefcSMark Murrayfollowing, among others, depending on the form of length 1404b528cefcSMark Murrayoctets and whether the encoding is primitive or constructed: 1405b528cefcSMark Murray 1406b528cefcSMark Murray14 0f DER encoding 1407b528cefcSMark Murray 63 6c c2 65 73 20 70 75 62 6c 69 71 75 65 73 1408b528cefcSMark Murray 1409b528cefcSMark Murray14 81 0f long form of length octets 1410b528cefcSMark Murray 63 6c c2 65 73 20 70 75 62 6c 69 71 75 65 73 1411b528cefcSMark Murray 1412b528cefcSMark Murray34 15 constructed encoding: "cl'es" + " " + "publiques" 1413b528cefcSMark Murray 14 05 63 6c c2 65 73 1414b528cefcSMark Murray 14 01 20 1415b528cefcSMark Murray 14 09 70 75 62 6c 69 71 75 65 73 1416b528cefcSMark Murray 1417b528cefcSMark MurrayThe eight-bit character c2 is a T.61 prefix that adds an 1418b528cefcSMark Murrayacute accent (') to the next character. 1419b528cefcSMark Murray 1420b528cefcSMark MurrayDER encoding. Primitive. Contents octets are as for a 1421b528cefcSMark Murrayprimitive BER encoding. 1422b528cefcSMark Murray 1423b528cefcSMark MurrayExample: The DER encoding of the T61String value "cl'es 1424b528cefcSMark Murraypubliques" is 1425b528cefcSMark Murray 1426b528cefcSMark Murray14 0f 63 6c c2 65 73 20 70 75 62 6c 69 71 75 65 73 1427b528cefcSMark Murray 1428b528cefcSMark Murray 1429b528cefcSMark Murray5.17 UTCTime 1430b528cefcSMark Murray 1431b528cefcSMark MurrayThe UTCTime type denotes a "coordinated universal time" or 1432b528cefcSMark MurrayGreenwich Mean Time (GMT) value. A UTCTime value includes 1433b528cefcSMark Murraythe local time precise to either minutes or seconds, and an 1434b528cefcSMark Murrayoffset from GMT in hours and minutes. It takes any of the 1435b528cefcSMark Murrayfollowing forms: 1436b528cefcSMark Murray 1437b528cefcSMark MurrayYYMMDDhhmmZ 1438b528cefcSMark MurrayYYMMDDhhmm+hh'mm' 1439b528cefcSMark MurrayYYMMDDhhmm-hh'mm' 1440b528cefcSMark MurrayYYMMDDhhmmssZ 1441b528cefcSMark MurrayYYMMDDhhmmss+hh'mm' 1442b528cefcSMark MurrayYYMMDDhhmmss-hh'mm' 1443b528cefcSMark Murray 1444b528cefcSMark Murraywhere: 1445b528cefcSMark Murray 1446b528cefcSMark Murray YY is the least significant two digits of the year 1447b528cefcSMark Murray 1448b528cefcSMark Murray MM is the month (01 to 12) 1449b528cefcSMark Murray 1450b528cefcSMark Murray DD is the day (01 to 31) 1451b528cefcSMark Murray 1452b528cefcSMark Murray hh is the hour (00 to 23) 1453b528cefcSMark Murray 1454b528cefcSMark Murray mm are the minutes (00 to 59) 1455b528cefcSMark Murray 1456b528cefcSMark Murray ss are the seconds (00 to 59) 1457b528cefcSMark Murray 1458b528cefcSMark Murray Z indicates that local time is GMT, + indicates that 1459b528cefcSMark Murray local time is later than GMT, and - indicates that 1460b528cefcSMark Murray local time is earlier than GMT 1461b528cefcSMark Murray 1462b528cefcSMark Murray hh' is the absolute value of the offset from GMT in 1463b528cefcSMark Murray hours 1464b528cefcSMark Murray 1465b528cefcSMark Murray mm' is the absolute value of the offset from GMT in 1466b528cefcSMark Murray minutes 1467b528cefcSMark Murray 1468b528cefcSMark MurrayThis type is a string type. 1469b528cefcSMark Murray 1470b528cefcSMark MurrayThe UTCTime type is used for signing times in PKCS #9's 1471b528cefcSMark Murraysigning-time attribute and for certificate validity periods 1472b528cefcSMark Murrayin X.509's Validity type. 1473b528cefcSMark Murray 1474b528cefcSMark MurrayASN.1 notation: 1475b528cefcSMark Murray 1476b528cefcSMark MurrayUTCTime 1477b528cefcSMark Murray 1478b528cefcSMark MurrayBER encoding. Primitive or constructed. In a primitive 1479b528cefcSMark Murrayencoding, the contents octets give the characters in the 1480b528cefcSMark Murraystring, encoded in ASCII. In a constructed encoding, the 1481b528cefcSMark Murraycontents octets give the concatenation of the BER encodings 1482b528cefcSMark Murrayof consecutive substrings of the string. (The constructed 1483b528cefcSMark Murrayencoding is not particularly interesting, since UTCTime 1484b528cefcSMark Murrayvalues are so short, but the constructed encoding is 1485b528cefcSMark Murraypermitted.) 1486b528cefcSMark Murray 1487b528cefcSMark MurrayExample: The time this sentence was originally written was 1488b528cefcSMark Murray4:45:40 p.m. Pacific Daylight Time on May 6, 1991, which can 1489b528cefcSMark Murraybe represented with either of the following UTCTime values, 1490b528cefcSMark Murrayamong others: 1491b528cefcSMark Murray 1492b528cefcSMark Murray"910506164540-0700" 1493b528cefcSMark Murray 1494b528cefcSMark Murray"910506234540Z" 1495b528cefcSMark Murray 1496b528cefcSMark MurrayThese values have the following BER encodings, among others: 1497b528cefcSMark Murray 1498b528cefcSMark Murray17 0d 39 31 30 35 30 36 32 33 34 35 34 30 5a 1499b528cefcSMark Murray 1500b528cefcSMark Murray17 11 39 31 30 35 30 36 31 36 34 35 34 30 2D 30 37 30 1501b528cefcSMark Murray 30 1502b528cefcSMark Murray 1503b528cefcSMark MurrayDER encoding. Primitive. Contents octets are as for a 1504b528cefcSMark Murrayprimitive BER encoding. 1505b528cefcSMark Murray 1506b528cefcSMark Murray 1507b528cefcSMark Murray6. An example 1508b528cefcSMark Murray 1509b528cefcSMark MurrayThis section gives an example of ASN.1 notation and DER 1510b528cefcSMark Murrayencoding: the X.501 type Name. 1511b528cefcSMark Murray 1512b528cefcSMark Murray 1513b528cefcSMark Murray6.1 Abstract notation 1514b528cefcSMark Murray 1515b528cefcSMark MurrayThis section gives the ASN.1 notation for the X.501 type 1516b528cefcSMark MurrayName. 1517b528cefcSMark Murray 1518b528cefcSMark MurrayName ::= CHOICE { 1519b528cefcSMark Murray RDNSequence } 1520b528cefcSMark Murray 1521b528cefcSMark MurrayRDNSequence ::= SEQUENCE OF RelativeDistinguishedName 1522b528cefcSMark Murray 1523b528cefcSMark MurrayRelativeDistinguishedName ::= 1524b528cefcSMark Murray SET OF AttributeValueAssertion 1525b528cefcSMark Murray 1526b528cefcSMark MurrayAttributeValueAssertion ::= SEQUENCE { 1527b528cefcSMark Murray AttributeType, 1528b528cefcSMark Murray AttributeValue } 1529b528cefcSMark Murray 1530b528cefcSMark MurrayAttributeType ::= OBJECT IDENTIFIER 1531b528cefcSMark Murray 1532b528cefcSMark MurrayAttributeValue ::= ANY 1533b528cefcSMark Murray 1534b528cefcSMark MurrayThe Name type identifies an object in an X.500 directory. 1535b528cefcSMark MurrayName is a CHOICE type consisting of one alternative: 1536b528cefcSMark MurrayRDNSequence. (Future revisions of X.500 may have other 1537b528cefcSMark Murrayalternatives.) 1538b528cefcSMark Murray 1539b528cefcSMark MurrayThe RDNSequence type gives a path through an X.500 directory 1540b528cefcSMark Murraytree starting at the root. RDNSequence is a SEQUENCE OF type 1541b528cefcSMark Murrayconsisting of zero or more occurences of 1542b528cefcSMark MurrayRelativeDistinguishedName. 1543b528cefcSMark Murray 1544b528cefcSMark MurrayThe RelativeDistinguishedName type gives a unique name to an 1545b528cefcSMark Murrayobject relative to the object superior to it in the 1546b528cefcSMark Murraydirectory tree. RelativeDistinguishedName is a SET OF type 1547b528cefcSMark Murrayconsisting of zero or more occurrences of 1548b528cefcSMark MurrayAttributeValueAssertion. 1549b528cefcSMark Murray 1550b528cefcSMark MurrayThe AttributeValueAssertion type assigns a value to some 1551b528cefcSMark Murrayattribute of a relative distinguished name, such as country 1552b528cefcSMark Murrayname or common name. AttributeValueAssertion is a SEQUENCE 1553b528cefcSMark Murraytype consisting of two components, an AttributeType type and 1554b528cefcSMark Murrayan AttributeValue type. 1555b528cefcSMark Murray 1556b528cefcSMark MurrayThe AttributeType type identifies an attribute by object 1557b528cefcSMark Murrayidentifier. The AttributeValue type gives an arbitrary 1558b528cefcSMark Murrayattribute value. The actual type of the attribute value is 1559b528cefcSMark Murraydetermined by the attribute type. 1560b528cefcSMark Murray 1561b528cefcSMark Murray 1562b528cefcSMark Murray6.2 DER encoding 1563b528cefcSMark Murray 1564b528cefcSMark MurrayThis section gives an example of a DER encoding of a value 1565b528cefcSMark Murrayof type Name, working from the bottom up. 1566b528cefcSMark Murray 1567b528cefcSMark MurrayThe name is that of the Test User 1 from the PKCS examples 1568b528cefcSMark Murray[Kal93]. The name is represented by the following path: 1569b528cefcSMark Murray 1570b528cefcSMark Murray (root) 1571b528cefcSMark Murray | 1572b528cefcSMark Murray countryName = "US" 1573b528cefcSMark Murray | 1574b528cefcSMark Murray organizationName = "Example Organization" 1575b528cefcSMark Murray | 1576b528cefcSMark Murray commonName = "Test User 1" 1577b528cefcSMark Murray 1578b528cefcSMark MurrayEach level corresponds to one RelativeDistinguishedName 1579b528cefcSMark Murrayvalue, each of which happens for this name to consist of one 1580b528cefcSMark MurrayAttributeValueAssertion value. The AttributeType value is 1581b528cefcSMark Murraybefore the equals sign, and the AttributeValue value (a 1582b528cefcSMark Murrayprintable string for the given attribute types) is after the 1583b528cefcSMark Murrayequals sign. 1584b528cefcSMark Murray 1585b528cefcSMark MurrayThe countryName, organizationName, and commonUnitName are 1586b528cefcSMark Murrayattribute types defined in X.520 as: 1587b528cefcSMark Murray 1588b528cefcSMark MurrayattributeType OBJECT IDENTIFIER ::= 1589b528cefcSMark Murray { joint-iso-ccitt(2) ds(5) 4 } 1590b528cefcSMark Murray 1591b528cefcSMark MurraycountryName OBJECT IDENTIFIER ::= { attributeType 6 } 1592b528cefcSMark MurrayorganizationName OBJECT IDENTIFIER ::= 1593b528cefcSMark Murray { attributeType 10 } 1594b528cefcSMark MurraycommonUnitName OBJECT IDENTIFIER ::= 1595b528cefcSMark Murray { attributeType 3 } 1596b528cefcSMark Murray 1597b528cefcSMark Murray 1598b528cefcSMark Murray6.2.1 AttributeType 1599b528cefcSMark Murray 1600b528cefcSMark MurrayThe three AttributeType values are OCTET STRING values, so 1601b528cefcSMark Murraytheir DER encoding follows the primitive, definite-length 1602b528cefcSMark Murraymethod: 1603b528cefcSMark Murray 1604b528cefcSMark Murray06 03 55 04 06 countryName 1605b528cefcSMark Murray 1606b528cefcSMark Murray06 03 55 04 0a organizationName 1607b528cefcSMark Murray 1608b528cefcSMark Murray06 03 55 04 03 commonName 1609b528cefcSMark Murray 1610b528cefcSMark MurrayThe identifier octets follow the low-tag form, since the tag 1611b528cefcSMark Murrayis 6 for OBJECT IDENTIFIER. Bits 8 and 7 have value "0," 1612b528cefcSMark Murrayindicating universal class, and bit 6 has value "0," 1613b528cefcSMark Murrayindicating that the encoding is primitive. The length octets 1614b528cefcSMark Murrayfollow the short form. The contents octets are the 1615b528cefcSMark Murrayconcatenation of three octet strings derived from 1616b528cefcSMark Murraysubidentifiers (in decimal): 40 * 2 + 5 = 85 = 5516; 4; and 1617b528cefcSMark Murray6, 10, or 3. 1618b528cefcSMark Murray 1619b528cefcSMark Murray 1620b528cefcSMark Murray6.2.2 AttributeValue 1621b528cefcSMark Murray 1622b528cefcSMark MurrayThe three AttributeValue values are PrintableString values, 1623b528cefcSMark Murrayso their encodings follow the primitive, definite-length 1624b528cefcSMark Murraymethod: 1625b528cefcSMark Murray 1626b528cefcSMark Murray13 02 55 53 "US" 1627b528cefcSMark Murray 1628b528cefcSMark Murray13 14 "Example Organization" 1629b528cefcSMark Murray 45 78 61 6d 70 6c 65 20 4f 72 67 61 6e 69 7a 61 1630b528cefcSMark Murray 74 69 6f 6e 1631b528cefcSMark Murray 1632b528cefcSMark Murray13 0b "Test User 1" 1633b528cefcSMark Murray 54 65 73 74 20 55 73 65 72 20 31 1634b528cefcSMark Murray 1635b528cefcSMark MurrayThe identifier octets follow the low-tag-number form, since 1636b528cefcSMark Murraythe tag for PrintableString, 19 (decimal), is between 0 and 1637b528cefcSMark Murray30. Bits 8 and 7 have value "0" since PrintableString is in 1638b528cefcSMark Murraythe universal class. Bit 6 has value "0" since the encoding 1639b528cefcSMark Murrayis primitive. The length octets follow the short form, and 1640b528cefcSMark Murraythe contents octets are the ASCII representation of the 1641b528cefcSMark Murrayattribute value. 1642b528cefcSMark Murray 1643b528cefcSMark Murray 1644b528cefcSMark Murray6.2.3 AttributeValueAssertion 1645b528cefcSMark Murray 1646b528cefcSMark MurrayThe three AttributeValueAssertion values are SEQUENCE 1647b528cefcSMark Murrayvalues, so their DER encodings follow the constructed, 1648b528cefcSMark Murraydefinite-length method: 1649b528cefcSMark Murray 1650b528cefcSMark Murray30 09 countryName = "US" 1651b528cefcSMark Murray 06 03 55 04 06 1652b528cefcSMark Murray 13 02 55 53 1653b528cefcSMark Murray 1654b528cefcSMark Murray30 1b organizationName = "Example Organizaiton" 1655b528cefcSMark Murray 06 03 55 04 0a 1656b528cefcSMark Murray 13 14 ... 6f 6e 1657b528cefcSMark Murray 1658b528cefcSMark Murray30 12 commonName = "Test User 1" 1659b528cefcSMark Murray 06 03 55 04 0b 1660b528cefcSMark Murray 13 0b ... 20 31 1661b528cefcSMark Murray 1662b528cefcSMark MurrayThe identifier octets follow the low-tag-number form, since 1663b528cefcSMark Murraythe tag for SEQUENCE, 16 (decimal), is between 0 and 30. 1664b528cefcSMark MurrayBits 8 and 7 have value "0" since SEQUENCE is in the 1665b528cefcSMark Murrayuniversal class. Bit 6 has value "1" since the encoding is 1666b528cefcSMark Murrayconstructed. The length octets follow the short form, and 1667b528cefcSMark Murraythe contents octets are the concatenation of the DER 1668b528cefcSMark Murrayencodings of the attributeType and attributeValue 1669b528cefcSMark Murraycomponents. 1670b528cefcSMark Murray 1671b528cefcSMark Murray 1672b528cefcSMark Murray6.2.4 RelativeDistinguishedName 1673b528cefcSMark Murray 1674b528cefcSMark MurrayThe three RelativeDistinguishedName values are SET OF 1675b528cefcSMark Murrayvalues, so their DER encodings follow the constructed, 1676b528cefcSMark Murraydefinite-length method: 1677b528cefcSMark Murray 1678b528cefcSMark Murray31 0b 1679b528cefcSMark Murray 30 09 ... 55 53 1680b528cefcSMark Murray 1681b528cefcSMark Murray31 1d 1682b528cefcSMark Murray 30 1b ... 6f 6e 1683b528cefcSMark Murray 1684b528cefcSMark Murray31 14 1685b528cefcSMark Murray 30 12 ... 20 31 1686b528cefcSMark Murray 1687b528cefcSMark MurrayThe identifier octets follow the low-tag-number form, since 1688b528cefcSMark Murraythe tag for SET OF, 17 (decimal), is between 0 and 30. Bits 1689b528cefcSMark Murray8 and 7 have value "0" since SET OF is in the universal 1690b528cefcSMark Murrayclass Bit 6 has value "1" since the encoding is constructed. 1691b528cefcSMark MurrayThe lengths octets follow the short form, and the contents 1692b528cefcSMark Murrayoctets are the DER encodings of the respective 1693b528cefcSMark MurrayAttributeValueAssertion values, since there is only one 1694b528cefcSMark Murrayvalue in each set. 1695b528cefcSMark Murray 1696b528cefcSMark Murray 1697b528cefcSMark Murray6.2.5 RDNSequence 1698b528cefcSMark Murray 1699b528cefcSMark MurrayThe RDNSequence value is a SEQUENCE OF value, so its DER 1700b528cefcSMark Murrayencoding follows the constructed, definite-length method: 1701b528cefcSMark Murray 1702b528cefcSMark Murray30 42 1703b528cefcSMark Murray 31 0b ... 55 53 1704b528cefcSMark Murray 31 1d ... 6f 6e 1705b528cefcSMark Murray 31 14 ... 20 31 1706b528cefcSMark Murray 1707b528cefcSMark MurrayThe identifier octets follow the low-tag-number form, since 1708b528cefcSMark Murraythe tag for SEQUENCE OF, 16 (decimal), is between 0 and 30. 1709b528cefcSMark MurrayBits 8 and 7 have value "0" since SEQUENCE OF is in the 1710b528cefcSMark Murrayuniversal class. Bit 6 has value "1" since the encoding is 1711b528cefcSMark Murrayconstructed. The lengths octets follow the short form, and 1712b528cefcSMark Murraythe contents octets are the concatenation of the DER 1713b528cefcSMark Murrayencodings of the three RelativeDistinguishedName values, in 1714b528cefcSMark Murrayorder of occurrence. 1715b528cefcSMark Murray 1716b528cefcSMark Murray 1717b528cefcSMark Murray6.2.6 Name 1718b528cefcSMark Murray 1719b528cefcSMark MurrayThe Name value is a CHOICE value, so its DER encoding is the 1720b528cefcSMark Murraysame as that of the RDNSequence value: 1721b528cefcSMark Murray 1722b528cefcSMark Murray30 42 1723b528cefcSMark Murray 31 0b 1724b528cefcSMark Murray 30 09 1725b528cefcSMark Murray 06 03 55 04 06 attributeType = countryName 1726b528cefcSMark Murray 13 02 55 53 attributeValue = "US" 1727b528cefcSMark Murray 31 1d 1728b528cefcSMark Murray 30 1b 1729b528cefcSMark Murray 06 03 55 04 0a attributeType = organizationName 1730b528cefcSMark Murray 13 14 attributeValue = "Example Organization" 1731b528cefcSMark Murray 45 78 61 6d 70 6c 65 20 4f 72 67 61 6e 69 7a 61 1732b528cefcSMark Murray 74 69 6f 6e 1733b528cefcSMark Murray 1734b528cefcSMark Murray 31 14 1735b528cefcSMark Murray 30 12 1736b528cefcSMark Murray 06 03 55 04 03 attributeType = commonName 1737b528cefcSMark Murray 13 0b attributeValue = "Test User 1" 1738b528cefcSMark Murray 54 65 73 74 20 55 73 65 72 20 31 1739b528cefcSMark Murray 1740b528cefcSMark Murray 1741b528cefcSMark MurrayReferences 1742b528cefcSMark Murray 1743b528cefcSMark MurrayPKCS #1 RSA Laboratories. PKCS #1: RSA Encryption 1744b528cefcSMark Murray Standard. Version 1.5, November 1993. 1745b528cefcSMark Murray 1746b528cefcSMark MurrayPKCS #3 RSA Laboratories. PKCS #3: Diffie-Hellman Key- 1747b528cefcSMark Murray Agreement Standard. Version 1.4, November 1993. 1748b528cefcSMark Murray 1749b528cefcSMark MurrayPKCS #5 RSA Laboratories. PKCS #5: Password-Based 1750b528cefcSMark Murray Encryption Standard. Version 1.5, November 1993. 1751b528cefcSMark Murray 1752b528cefcSMark MurrayPKCS #6 RSA Laboratories. PKCS #6: Extended-Certificate 1753b528cefcSMark Murray Syntax Standard. Version 1.5, November 1993. 1754b528cefcSMark Murray 1755b528cefcSMark MurrayPKCS #7 RSA Laboratories. PKCS #7: Cryptographic Message 1756b528cefcSMark Murray Syntax Standard. Version 1.5, November 1993. 1757b528cefcSMark Murray 1758b528cefcSMark MurrayPKCS #8 RSA Laboratories. PKCS #8: Private-Key Information 1759b528cefcSMark Murray Syntax Standard. Version 1.2, November 1993. 1760b528cefcSMark Murray 1761b528cefcSMark MurrayPKCS #9 RSA Laboratories. PKCS #9: Selected Attribute 1762b528cefcSMark Murray Types. Version 1.1, November 1993. 1763b528cefcSMark Murray 1764b528cefcSMark MurrayPKCS #10 RSA Laboratories. PKCS #10: Certification Request 1765b528cefcSMark Murray Syntax Standard. Version 1.0, November 1993. 1766b528cefcSMark Murray 1767b528cefcSMark MurrayX.200 CCITT. Recommendation X.200: Reference Model of 1768b528cefcSMark Murray Open Systems Interconnection for CCITT 1769b528cefcSMark Murray Applications. 1984. 1770b528cefcSMark Murray 1771b528cefcSMark MurrayX.208 CCITT. Recommendation X.208: Specification of 1772b528cefcSMark Murray Abstract Syntax Notation One (ASN.1). 1988. 1773b528cefcSMark Murray 1774b528cefcSMark MurrayX.209 CCITT. Recommendation X.209: Specification of 1775b528cefcSMark Murray Basic Encoding Rules for Abstract Syntax Notation 1776b528cefcSMark Murray One (ASN.1). 1988. 1777b528cefcSMark Murray 1778b528cefcSMark MurrayX.500 CCITT. Recommendation X.500: The 1779b528cefcSMark Murray Directory--Overview of Concepts, Models and 1780b528cefcSMark Murray Services. 1988. 1781b528cefcSMark Murray 1782b528cefcSMark MurrayX.501 CCITT. Recommendation X.501: The Directory-- 1783b528cefcSMark Murray Models. 1988. 1784b528cefcSMark Murray 1785b528cefcSMark MurrayX.509 CCITT. Recommendation X.509: The Directory-- 1786b528cefcSMark Murray Authentication Framework. 1988. 1787b528cefcSMark Murray 1788b528cefcSMark MurrayX.520 CCITT. Recommendation X.520: The Directory-- 1789b528cefcSMark Murray Selected Attribute Types. 1988. 1790b528cefcSMark Murray 1791b528cefcSMark Murray[Kal93] Burton S. Kaliski Jr. Some Examples of the PKCS 1792b528cefcSMark Murray Standards. RSA Laboratories, November 1993. 1793b528cefcSMark Murray 1794b528cefcSMark Murray[NIST92] NIST. Special Publication 500-202: Stable 1795b528cefcSMark Murray Implementation Agreements for Open Systems 1796b528cefcSMark Murray Interconnection Protocols. Part 11 (Directory 1797b528cefcSMark Murray Services Protocols). December 1992. 1798b528cefcSMark Murray 1799b528cefcSMark Murray 1800b528cefcSMark MurrayRevision history 1801b528cefcSMark Murray 1802b528cefcSMark Murray 1803b528cefcSMark MurrayJune 3, 1991 version 1804b528cefcSMark Murray 1805b528cefcSMark MurrayThe June 3, 1991 version is part of the initial public 1806b528cefcSMark Murrayrelease of PKCS. It was published as NIST/OSI Implementors' 1807b528cefcSMark MurrayWorkshop document SEC-SIG-91-17. 1808b528cefcSMark Murray 1809b528cefcSMark Murray 1810b528cefcSMark MurrayNovember 1, 1993 version 1811b528cefcSMark Murray 1812b528cefcSMark MurrayThe November 1, 1993 version incorporates several editorial 1813b528cefcSMark Murraychanges, including the addition of a revision history. It is 1814b528cefcSMark Murrayupdated to be consistent with the following versions of the 1815b528cefcSMark MurrayPKCS documents: 1816b528cefcSMark Murray 1817b528cefcSMark Murray PKCS #1: RSA Encryption Standard. Version 1.5, November 1818b528cefcSMark Murray 1993. 1819b528cefcSMark Murray 1820b528cefcSMark Murray PKCS #3: Diffie-Hellman Key-Agreement Standard. Version 1821b528cefcSMark Murray 1.4, November 1993. 1822b528cefcSMark Murray 1823b528cefcSMark Murray PKCS #5: Password-Based Encryption Standard. Version 1824b528cefcSMark Murray 1.5, November 1993. 1825b528cefcSMark Murray 1826b528cefcSMark Murray PKCS #6: Extended-Certificate Syntax Standard. Version 1827b528cefcSMark Murray 1.5, November 1993. 1828b528cefcSMark Murray 1829b528cefcSMark Murray PKCS #7: Cryptographic Message Syntax Standard. Version 1830b528cefcSMark Murray 1.5, November 1993. 1831b528cefcSMark Murray 1832b528cefcSMark Murray PKCS #8: Private-Key Information Syntax Standard. 1833b528cefcSMark Murray Version 1.2, November 1993. 1834b528cefcSMark Murray 1835b528cefcSMark Murray PKCS #9: Selected Attribute Types. Version 1.1, 1836b528cefcSMark Murray November 1993. 1837b528cefcSMark Murray 1838b528cefcSMark Murray PKCS #10: Certification Request Syntax Standard. 1839b528cefcSMark Murray Version 1.0, November 1993. 1840b528cefcSMark Murray 1841b528cefcSMark MurrayThe following substantive changes were made: 1842b528cefcSMark Murray 1843b528cefcSMark Murray Section 5: Description of T61String type is added. 1844b528cefcSMark Murray 1845b528cefcSMark Murray Section 6: Names are changed, consistent with other 1846b528cefcSMark Murray PKCS examples. 1847b528cefcSMark Murray 1848b528cefcSMark Murray 1849b528cefcSMark MurrayAuthor's address 1850b528cefcSMark Murray 1851b528cefcSMark MurrayBurton S. Kaliski Jr., Ph.D. 1852b528cefcSMark MurrayChief Scientist 1853b528cefcSMark MurrayRSA Laboratories (415) 595-7703 1854b528cefcSMark Murray100 Marine Parkway (415) 595-4126 (fax) 1855b528cefcSMark MurrayRedwood City, CA 94065 USA burt@rsa.com 1856