PageRenderTime 54ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 1ms

/crypto/heimdal/doc/layman.asc

https://bitbucket.org/freebsd/freebsd-head/
Unknown | 1855 lines | 1342 code | 513 blank | 0 comment | 0 complexity | dbe47a235c7b1da117037a3c7882669b MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, BSD-3-Clause, LGPL-2.0, LGPL-2.1, BSD-2-Clause, 0BSD, JSON, AGPL-1.0, GPL-2.0
  1. A Layman's Guide to a Subset of ASN.1, BER, and DER
  2. An RSA Laboratories Technical Note
  3. Burton S. Kaliski Jr.
  4. Revised November 1, 1993
  5. Supersedes June 3, 1991 version, which was also published as
  6. NIST/OSI Implementors' Workshop document SEC-SIG-91-17.
  7. PKCS documents are available by electronic mail to
  8. <pkcs@rsa.com>.
  9. Copyright (C) 1991-1993 RSA Laboratories, a division of RSA
  10. Data Security, Inc. License to copy this document is granted
  11. provided that it is identified as "RSA Data Security, Inc.
  12. Public-Key Cryptography Standards (PKCS)" in all material
  13. mentioning or referencing this document.
  14. 003-903015-110-000-000
  15. Abstract. This note gives a layman's introduction to a
  16. subset of OSI's Abstract Syntax Notation One (ASN.1), Basic
  17. Encoding Rules (BER), and Distinguished Encoding Rules
  18. (DER). The particular purpose of this note is to provide
  19. background material sufficient for understanding and
  20. implementing the PKCS family of standards.
  21. 1. Introduction
  22. It is a generally accepted design principle that abstraction
  23. is a key to managing software development. With abstraction,
  24. a designer can specify a part of a system without concern
  25. for how the part is actually implemented or represented.
  26. Such a practice leaves the implementation open; it
  27. simplifies the specification; and it makes it possible to
  28. state "axioms" about the part that can be proved when the
  29. part is implemented, and assumed when the part is employed
  30. in another, higher-level part. Abstraction is the hallmark
  31. of most modern software specifications.
  32. One of the most complex systems today, and one that also
  33. involves a great deal of abstraction, is Open Systems
  34. Interconnection (OSI, described in X.200). OSI is an
  35. internationally standardized architecture that governs the
  36. interconnection of computers from the physical layer up to
  37. the user application layer. Objects at higher layers are
  38. defined abstractly and intended to be implemented with
  39. objects at lower layers. For instance, a service at one
  40. layer may require transfer of certain abstract objects
  41. between computers; a lower layer may provide transfer
  42. services for strings of ones and zeroes, using encoding
  43. rules to transform the abstract objects into such strings.
  44. OSI is called an open system because it supports many
  45. different implementations of the services at each layer.
  46. OSI's method of specifying abstract objects is called ASN.1
  47. (Abstract Syntax Notation One, defined in X.208), and one
  48. set of rules for representing such objects as strings of
  49. ones and zeros is called the BER (Basic Encoding Rules,
  50. defined in X.209). ASN.1 is a flexible notation that allows
  51. one to define a variety data types, from simple types such
  52. as integers and bit strings to structured types such as sets
  53. and sequences, as well as complex types defined in terms of
  54. others. BER describes how to represent or encode values of
  55. each ASN.1 type as a string of eight-bit octets. There is
  56. generally more than one way to BER-encode a given value.
  57. Another set of rules, called the Distinguished Encoding
  58. Rules (DER), which is a subset of BER, gives a unique
  59. encoding to each ASN.1 value.
  60. The purpose of this note is to describe a subset of ASN.1,
  61. BER and DER sufficient to understand and implement one OSI-
  62. based application, RSA Data Security, Inc.'s Public-Key
  63. Cryptography Standards. The features described include an
  64. overview of ASN.1, BER, and DER and an abridged list of
  65. ASN.1 types and their BER and DER encodings. Sections 2-4
  66. give an overview of ASN.1, BER, and DER, in that order.
  67. Section 5 lists some ASN.1 types, giving their notation,
  68. specific encoding rules, examples, and comments about their
  69. application to PKCS. Section 6 concludes with an example,
  70. X.500 distinguished names.
  71. Advanced features of ASN.1, such as macros, are not
  72. described in this note, as they are not needed to implement
  73. PKCS. For information on the other features, and for more
  74. detail generally, the reader is referred to CCITT
  75. Recommendations X.208 and X.209, which define ASN.1 and BER.
  76. Terminology and notation. In this note, an octet is an eight-
  77. bit unsigned integer. Bit 8 of the octet is the most
  78. significant and bit 1 is the least significant.
  79. The following meta-syntax is used for in describing ASN.1
  80. notation:
  81. BIT monospace denotes literal characters in the type
  82. and value notation; in examples, it generally
  83. denotes an octet value in hexadecimal
  84. n1 bold italics denotes a variable
  85. [] bold square brackets indicate that a term is
  86. optional
  87. {} bold braces group related terms
  88. | bold vertical bar delimits alternatives with a
  89. group
  90. ... bold ellipsis indicates repeated occurrences
  91. = bold equals sign expresses terms as subterms
  92. 2. Abstract Syntax Notation One
  93. Abstract Syntax Notation One, abbreviated ASN.1, is a
  94. notation for describing abstract types and values.
  95. In ASN.1, a type is a set of values. For some types, there
  96. are a finite number of values, and for other types there are
  97. an infinite number. A value of a given ASN.1 type is an
  98. element of the type's set. ASN.1 has four kinds of type:
  99. simple types, which are "atomic" and have no components;
  100. structured types, which have components; tagged types, which
  101. are derived from other types; and other types, which include
  102. the CHOICE type and the ANY type. Types and values can be
  103. given names with the ASN.1 assignment operator (::=) , and
  104. those names can be used in defining other types and values.
  105. Every ASN.1 type other than CHOICE and ANY has a tag, which
  106. consists of a class and a nonnegative tag number. ASN.1
  107. types are abstractly the same if and only if their tag
  108. numbers are the same. In other words, the name of an ASN.1
  109. type does not affect its abstract meaning, only the tag
  110. does. There are four classes of tag:
  111. Universal, for types whose meaning is the same in all
  112. applications; these types are only defined in
  113. X.208.
  114. Application, for types whose meaning is specific to an
  115. application, such as X.500 directory services;
  116. types in two different applications may have the
  117. same application-specific tag and different
  118. meanings.
  119. Private, for types whose meaning is specific to a given
  120. enterprise.
  121. Context-specific, for types whose meaning is specific
  122. to a given structured type; context-specific tags
  123. are used to distinguish between component types
  124. with the same underlying tag within the context of
  125. a given structured type, and component types in
  126. two different structured types may have the same
  127. tag and different meanings.
  128. The types with universal tags are defined in X.208, which
  129. also gives the types' universal tag numbers. Types with
  130. other tags are defined in many places, and are always
  131. obtained by implicit or explicit tagging (see Section 2.3).
  132. Table 1 lists some ASN.1 types and their universal-class
  133. tags.
  134. Type Tag number Tag number
  135. (decimal) (hexadecimal)
  136. INTEGER 2 02
  137. BIT STRING 3 03
  138. OCTET STRING 4 04
  139. NULL 5 05
  140. OBJECT IDENTIFIER 6 06
  141. SEQUENCE and SEQUENCE OF 16 10
  142. SET and SET OF 17 11
  143. PrintableString 19 13
  144. T61String 20 14
  145. IA5String 22 16
  146. UTCTime 23 17
  147. Table 1. Some types and their universal-class tags.
  148. ASN.1 types and values are expressed in a flexible,
  149. programming-language-like notation, with the following
  150. special rules:
  151. o Layout is not significant; multiple spaces and
  152. line breaks can be considered as a single space.
  153. o Comments are delimited by pairs of hyphens (--),
  154. or a pair of hyphens and a line break.
  155. o Identifiers (names of values and fields) and type
  156. references (names of types) consist of upper- and
  157. lower-case letters, digits, hyphens, and spaces;
  158. identifiers begin with lower-case letters; type
  159. references begin with upper-case letters.
  160. The following four subsections give an overview of simple
  161. types, structured types, implicitly and explicitly tagged
  162. types, and other types. Section 5 describes specific types
  163. in more detail.
  164. 2.1 Simple types
  165. Simple types are those not consisting of components; they
  166. are the "atomic" types. ASN.1 defines several; the types
  167. that are relevant to the PKCS standards are the following:
  168. BIT STRING, an arbitrary string of bits (ones and
  169. zeroes).
  170. IA5String, an arbitrary string of IA5 (ASCII)
  171. characters.
  172. INTEGER, an arbitrary integer.
  173. NULL, a null value.
  174. OBJECT IDENTIFIER, an object identifier, which is a
  175. sequence of integer components that identify an
  176. object such as an algorithm or attribute type.
  177. OCTET STRING, an arbitrary string of octets (eight-bit
  178. values).
  179. PrintableString, an arbitrary string of printable
  180. characters.
  181. T61String, an arbitrary string of T.61 (eight-bit)
  182. characters.
  183. UTCTime, a "coordinated universal time" or Greenwich
  184. Mean Time (GMT) value.
  185. Simple types fall into two categories: string types and non-
  186. string types. BIT STRING, IA5String, OCTET STRING,
  187. PrintableString, T61String, and UTCTime are string types.
  188. String types can be viewed, for the purposes of encoding, as
  189. consisting of components, where the components are
  190. substrings. This view allows one to encode a value whose
  191. length is not known in advance (e.g., an octet string value
  192. input from a file stream) with a constructed, indefinite-
  193. length encoding (see Section 3).
  194. The string types can be given size constraints limiting the
  195. length of values.
  196. 2.2 Structured types
  197. Structured types are those consisting of components. ASN.1
  198. defines four, all of which are relevant to the PKCS
  199. standards:
  200. SEQUENCE, an ordered collection of one or more types.
  201. SEQUENCE OF, an ordered collection of zero or more
  202. occurrences of a given type.
  203. SET, an unordered collection of one or more types.
  204. SET OF, an unordered collection of zero or more
  205. occurrences of a given type.
  206. The structured types can have optional components, possibly
  207. with default values.
  208. 2.3 Implicitly and explicitly tagged types
  209. Tagging is useful to distinguish types within an
  210. application; it is also commonly used to distinguish
  211. component types within a structured type. For instance,
  212. optional components of a SET or SEQUENCE type are typically
  213. given distinct context-specific tags to avoid ambiguity.
  214. There are two ways to tag a type: implicitly and explicitly.
  215. Implicitly tagged types are derived from other types by
  216. changing the tag of the underlying type. Implicit tagging is
  217. denoted by the ASN.1 keywords [class number] IMPLICIT (see
  218. Section 5.1).
  219. Explicitly tagged types are derived from other types by
  220. adding an outer tag to the underlying type. In effect,
  221. explicitly tagged types are structured types consisting of
  222. one component, the underlying type. Explicit tagging is
  223. denoted by the ASN.1 keywords [class number] EXPLICIT (see
  224. Section 5.2).
  225. The keyword [class number] alone is the same as explicit
  226. tagging, except when the "module" in which the ASN.1 type is
  227. defined has implicit tagging by default. ("Modules" are
  228. among the advanced features not described in this note.)
  229. For purposes of encoding, an implicitly tagged type is
  230. considered the same as the underlying type, except that the
  231. tag is different. An explicitly tagged type is considered
  232. like a structured type with one component, the underlying
  233. type. Implicit tags result in shorter encodings, but
  234. explicit tags may be necessary to avoid ambiguity if the tag
  235. of the underlying type is indeterminate (e.g., the
  236. underlying type is CHOICE or ANY).
  237. 2.4 Other types
  238. Other types in ASN.1 include the CHOICE and ANY types. The
  239. CHOICE type denotes a union of one or more alternatives; the
  240. ANY type denotes an arbitrary value of an arbitrary type,
  241. where the arbitrary type is possibly defined in the
  242. registration of an object identifier or integer value.
  243. 3. Basic Encoding Rules
  244. The Basic Encoding Rules for ASN.1, abbreviated BER, give
  245. one or more ways to represent any ASN.1 value as an octet
  246. string. (There are certainly other ways to represent ASN.1
  247. values, but BER is the standard for interchanging such
  248. values in OSI.)
  249. There are three methods to encode an ASN.1 value under BER,
  250. the choice of which depends on the type of value and whether
  251. the length of the value is known. The three methods are
  252. primitive, definite-length encoding; constructed, definite-
  253. length encoding; and constructed, indefinite-length
  254. encoding. Simple non-string types employ the primitive,
  255. definite-length method; structured types employ either of
  256. the constructed methods; and simple string types employ any
  257. of the methods, depending on whether the length of the value
  258. is known. Types derived by implicit tagging employ the
  259. method of the underlying type and types derived by explicit
  260. tagging employ the constructed methods.
  261. In each method, the BER encoding has three or four parts:
  262. Identifier octets. These identify the class and tag
  263. number of the ASN.1 value, and indicate whether
  264. the method is primitive or constructed.
  265. Length octets. For the definite-length methods, these
  266. give the number of contents octets. For the
  267. constructed, indefinite-length method, these
  268. indicate that the length is indefinite.
  269. Contents octets. For the primitive, definite-length
  270. method, these give a concrete representation of
  271. the value. For the constructed methods, these
  272. give the concatenation of the BER encodings of the
  273. components of the value.
  274. End-of-contents octets. For the constructed, indefinite-
  275. length method, these denote the end of the
  276. contents. For the other methods, these are absent.
  277. The three methods of encoding are described in the following
  278. sections.
  279. 3.1 Primitive, definite-length method
  280. This method applies to simple types and types derived from
  281. simple types by implicit tagging. It requires that the
  282. length of the value be known in advance. The parts of the
  283. BER encoding are as follows:
  284. Identifier octets. There are two forms: low tag number (for
  285. tag numbers between 0 and 30) and high tag number (for tag
  286. numbers 31 and greater).
  287. Low-tag-number form. One octet. Bits 8 and 7 specify
  288. the class (see Table 2), bit 6 has value "0,"
  289. indicating that the encoding is primitive, and
  290. bits 5-1 give the tag number.
  291. Class Bit Bit
  292. 8 7
  293. universal 0 0
  294. application 0 1
  295. context-specific 1 0
  296. private 1 1
  297. Table 2. Class encoding in identifier octets.
  298. High-tag-number form. Two or more octets. First octet
  299. is as in low-tag-number form, except that bits 5-1
  300. all have value "1." Second and following octets
  301. give the tag number, base 128, most significant
  302. digit first, with as few digits as possible, and
  303. with the bit 8 of each octet except the last set
  304. to "1."
  305. Length octets. There are two forms: short (for lengths
  306. between 0 and 127), and long definite (for lengths between 0
  307. and 21008-1).
  308. Short form. One octet. Bit 8 has value "0" and bits 7-1
  309. give the length.
  310. Long form. Two to 127 octets. Bit 8 of first octet has
  311. value "1" and bits 7-1 give the number of
  312. additional length octets. Second and following
  313. octets give the length, base 256, most significant
  314. digit first.
  315. Contents octets. These give a concrete representation of the
  316. value (or the value of the underlying type, if the type is
  317. derived by implicit tagging). Details for particular types
  318. are given in Section 5.
  319. 3.2 Constructed, definite-length method
  320. This method applies to simple string types, structured
  321. types, types derived simple string types and structured
  322. types by implicit tagging, and types derived from anything
  323. by explicit tagging. It requires that the length of the
  324. value be known in advance. The parts of the BER encoding are
  325. as follows:
  326. Identifier octets. As described in Section 3.1, except that
  327. bit 6 has value "1," indicating that the encoding is
  328. constructed.
  329. Length octets. As described in Section 3.1.
  330. Contents octets. The concatenation of the BER encodings of
  331. the components of the value:
  332. o For simple string types and types derived from
  333. them by implicit tagging, the concatenation of the
  334. BER encodings of consecutive substrings of the
  335. value (underlying value for implicit tagging).
  336. o For structured types and types derived from them
  337. by implicit tagging, the concatenation of the BER
  338. encodings of components of the value (underlying
  339. value for implicit tagging).
  340. o For types derived from anything by explicit
  341. tagging, the BER encoding of the underlying value.
  342. Details for particular types are given in Section 5.
  343. 3.3 Constructed, indefinite-length method
  344. This method applies to simple string types, structured
  345. types, types derived simple string types and structured
  346. types by implicit tagging, and types derived from anything
  347. by explicit tagging. It does not require that the length of
  348. the value be known in advance. The parts of the BER encoding
  349. are as follows:
  350. Identifier octets. As described in Section 3.2.
  351. Length octets. One octet, 80.
  352. Contents octets. As described in Section 3.2.
  353. End-of-contents octets. Two octets, 00 00.
  354. Since the end-of-contents octets appear where an ordinary
  355. BER encoding might be expected (e.g., in the contents octets
  356. of a sequence value), the 00 and 00 appear as identifier and
  357. length octets, respectively. Thus the end-of-contents octets
  358. is really the primitive, definite-length encoding of a value
  359. with universal class, tag number 0, and length 0.
  360. 4. Distinguished Encoding Rules
  361. The Distinguished Encoding Rules for ASN.1, abbreviated DER,
  362. are a subset of BER, and give exactly one way to represent
  363. any ASN.1 value as an octet string. DER is intended for
  364. applications in which a unique octet string encoding is
  365. needed, as is the case when a digital signature is computed
  366. on an ASN.1 value. DER is defined in Section 8.7 of X.509.
  367. DER adds the following restrictions to the rules given in
  368. Section 3:
  369. 1. When the length is between 0 and 127, the short
  370. form of length must be used
  371. 2. When the length is 128 or greater, the long form
  372. of length must be used, and the length must be
  373. encoded in the minimum number of octets.
  374. 3. For simple string types and implicitly tagged
  375. types derived from simple string types, the
  376. primitive, definite-length method must be
  377. employed.
  378. 4. For structured types, implicitly tagged types
  379. derived from structured types, and explicitly
  380. tagged types derived from anything, the
  381. constructed, definite-length method must be
  382. employed.
  383. Other restrictions are defined for particular types (such as
  384. BIT STRING, SEQUENCE, SET, and SET OF), and can be found in
  385. Section 5.
  386. 5. Notation and encodings for some types
  387. This section gives the notation for some ASN.1 types and
  388. describes how to encode values of those types under both BER
  389. and DER.
  390. The types described are those presented in Section 2. They
  391. are listed alphabetically here.
  392. Each description includes ASN.1 notation, BER encoding, and
  393. DER encoding. The focus of the encodings is primarily on the
  394. contents octets; the tag and length octets follow Sections 3
  395. and 4. The descriptions also explain where each type is used
  396. in PKCS and related standards. ASN.1 notation is generally
  397. only for types, although for the type OBJECT IDENTIFIER,
  398. value notation is given as well.
  399. 5.1 Implicitly tagged types
  400. An implicitly tagged type is a type derived from another
  401. type by changing the tag of the underlying type.
  402. Implicit tagging is used for optional SEQUENCE components
  403. with underlying type other than ANY throughout PKCS, and for
  404. the extendedCertificate alternative of PKCS #7's
  405. ExtendedCertificateOrCertificate type.
  406. ASN.1 notation:
  407. [[class] number] IMPLICIT Type
  408. class = UNIVERSAL | APPLICATION | PRIVATE
  409. where Type is a type, class is an optional class name, and
  410. number is the tag number within the class, a nonnegative
  411. integer.
  412. In ASN.1 "modules" whose default tagging method is implicit
  413. tagging, the notation [[class] number] Type is also
  414. acceptable, and the keyword IMPLICIT is implied. (See
  415. Section 2.3.) For definitions stated outside a module, the
  416. explicit inclusion of the keyword IMPLICIT is preferable to
  417. prevent ambiguity.
  418. If the class name is absent, then the tag is context-
  419. specific. Context-specific tags can only appear in a
  420. component of a structured or CHOICE type.
  421. Example: PKCS #8's PrivateKeyInfo type has an optional
  422. attributes component with an implicit, context-specific tag:
  423. PrivateKeyInfo ::= SEQUENCE {
  424. version Version,
  425. privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
  426. privateKey PrivateKey,
  427. attributes [0] IMPLICIT Attributes OPTIONAL }
  428. Here the underlying type is Attributes, the class is absent
  429. (i.e., context-specific), and the tag number within the
  430. class is 0.
  431. BER encoding. Primitive or constructed, depending on the
  432. underlying type. Contents octets are as for the BER encoding
  433. of the underlying value.
  434. Example: The BER encoding of the attributes component of a
  435. PrivateKeyInfo value is as follows:
  436. o the identifier octets are 80 if the underlying
  437. Attributes value has a primitive BER encoding and
  438. a0 if the underlying Attributes value has a
  439. constructed BER encoding
  440. o the length and contents octets are the same as the
  441. length and contents octets of the BER encoding of
  442. the underlying Attributes value
  443. DER encoding. Primitive or constructed, depending on the
  444. underlying type. Contents octets are as for the DER encoding
  445. of the underlying value.
  446. 5.2 Explicitly tagged types
  447. Explicit tagging denotes a type derived from another type by
  448. adding an outer tag to the underlying type.
  449. Explicit tagging is used for optional SEQUENCE components
  450. with underlying type ANY throughout PKCS, and for the
  451. version component of X.509's Certificate type.
  452. ASN.1 notation:
  453. [[class] number] EXPLICIT Type
  454. class = UNIVERSAL | APPLICATION | PRIVATE
  455. where Type is a type, class is an optional class name, and
  456. number is the tag number within the class, a nonnegative
  457. integer.
  458. If the class name is absent, then the tag is context-
  459. specific. Context-specific tags can only appear in a
  460. component of a SEQUENCE, SET or CHOICE type.
  461. In ASN.1 "modules" whose default tagging method is explicit
  462. tagging, the notation [[class] number] Type is also
  463. acceptable, and the keyword EXPLICIT is implied. (See
  464. Section 2.3.) For definitions stated outside a module, the
  465. explicit inclusion of the keyword EXPLICIT is preferable to
  466. prevent ambiguity.
  467. Example 1: PKCS #7's ContentInfo type has an optional
  468. content component with an explicit, context-specific tag:
  469. ContentInfo ::= SEQUENCE {
  470. contentType ContentType,
  471. content
  472. [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL }
  473. Here the underlying type is ANY DEFINED BY contentType, the
  474. class is absent (i.e., context-specific), and the tag number
  475. within the class is 0.
  476. Example 2: X.509's Certificate type has a version component
  477. with an explicit, context-specific tag, where the EXPLICIT
  478. keyword is omitted:
  479. Certificate ::= ...
  480. version [0] Version DEFAULT v1988,
  481. ...
  482. The tag is explicit because the default tagging method for
  483. the ASN.1 "module" in X.509 that defines the Certificate
  484. type is explicit tagging.
  485. BER encoding. Constructed. Contents octets are the BER
  486. encoding of the underlying value.
  487. Example: the BER encoding of the content component of a
  488. ContentInfo value is as follows:
  489. o identifier octets are a0
  490. o length octets represent the length of the BER
  491. encoding of the underlying ANY DEFINED BY
  492. contentType value
  493. o contents octets are the BER encoding of the
  494. underlying ANY DEFINED BY contentType value
  495. DER encoding. Constructed. Contents octets are the DER
  496. encoding of the underlying value.
  497. 5.3 ANY
  498. The ANY type denotes an arbitrary value of an arbitrary
  499. type, where the arbitrary type is possibly defined in the
  500. registration of an object identifier or associated with an
  501. integer index.
  502. The ANY type is used for content of a particular content
  503. type in PKCS #7's ContentInfo type, for parameters of a
  504. particular algorithm in X.509's AlgorithmIdentifier type,
  505. and for attribute values in X.501's Attribute and
  506. AttributeValueAssertion types. The Attribute type is used by
  507. PKCS #6, #7, #8, #9 and #10, and the AttributeValueAssertion
  508. type is used in X.501 distinguished names.
  509. ASN.1 notation:
  510. ANY [DEFINED BY identifier]
  511. where identifier is an optional identifier.
  512. In the ANY form, the actual type is indeterminate.
  513. The ANY DEFINED BY identifier form can only appear in a
  514. component of a SEQUENCE or SET type for which identifier
  515. identifies some other component, and that other component
  516. has type INTEGER or OBJECT IDENTIFIER (or a type derived
  517. from either of those by tagging). In that form, the actual
  518. type is determined by the value of the other component,
  519. either in the registration of the object identifier value,
  520. or in a table of integer values.
  521. Example: X.509's AlgorithmIdentifier type has a component of
  522. type ANY:
  523. AlgorithmIdentifier ::= SEQUENCE {
  524. algorithm OBJECT IDENTIFIER,
  525. parameters ANY DEFINED BY algorithm OPTIONAL }
  526. Here the actual type of the parameter component depends on
  527. the value of the algorithm component. The actual type would
  528. be defined in the registration of object identifier values
  529. for the algorithm component.
  530. BER encoding. Same as the BER encoding of the actual value.
  531. Example: The BER encoding of the value of the parameter
  532. component is the BER encoding of the value of the actual
  533. type as defined in the registration of object identifier
  534. values for the algorithm component.
  535. DER encoding. Same as the DER encoding of the actual value.
  536. 5.4 BIT STRING
  537. The BIT STRING type denotes an arbitrary string of bits
  538. (ones and zeroes). A BIT STRING value can have any length,
  539. including zero. This type is a string type.
  540. The BIT STRING type is used for digital signatures on
  541. extended certificates in PKCS #6's ExtendedCertificate type,
  542. for digital signatures on certificates in X.509's
  543. Certificate type, and for public keys in certificates in
  544. X.509's SubjectPublicKeyInfo type.
  545. ASN.1 notation:
  546. BIT STRING
  547. Example: X.509's SubjectPublicKeyInfo type has a component
  548. of type BIT STRING:
  549. SubjectPublicKeyInfo ::= SEQUENCE {
  550. algorithm AlgorithmIdentifier,
  551. publicKey BIT STRING }
  552. BER encoding. Primitive or constructed. In a primitive
  553. encoding, the first contents octet gives the number of bits
  554. by which the length of the bit string is less than the next
  555. multiple of eight (this is called the "number of unused
  556. bits"). The second and following contents octets give the
  557. value of the bit string, converted to an octet string. The
  558. conversion process is as follows:
  559. 1. The bit string is padded after the last bit with
  560. zero to seven bits of any value to make the length
  561. of the bit string a multiple of eight. If the
  562. length of the bit string is a multiple of eight
  563. already, no padding is done.
  564. 2. The padded bit string is divided into octets. The
  565. first eight bits of the padded bit string become
  566. the first octet, bit 8 to bit 1, and so on through
  567. the last eight bits of the padded bit string.
  568. In a constructed encoding, the contents octets give the
  569. concatenation of the BER encodings of consecutive substrings
  570. of the bit string, where each substring except the last has
  571. a length that is a multiple of eight bits.
  572. Example: The BER encoding of the BIT STRING value
  573. "011011100101110111" can be any of the following, among
  574. others, depending on the choice of padding bits, the form of
  575. length octets, and whether the encoding is primitive or
  576. constructed:
  577. 03 04 06 6e 5d c0 DER encoding
  578. 03 04 06 6e 5d e0 padded with "100000"
  579. 03 81 04 06 6e 5d c0 long form of length octets
  580. 23 09 constructed encoding: "0110111001011101" + "11"
  581. 03 03 00 6e 5d
  582. 03 02 06 c0
  583. DER encoding. Primitive. The contents octects are as for a
  584. primitive BER encoding, except that the bit string is padded
  585. with zero-valued bits.
  586. Example: The DER encoding of the BIT STRING value
  587. "011011100101110111" is
  588. 03 04 06 6e 5d c0
  589. 5.5 CHOICE
  590. The CHOICE type denotes a union of one or more alternatives.
  591. The CHOICE type is used to represent the union of an
  592. extended certificate and an X.509 certificate in PKCS #7's
  593. ExtendedCertificateOrCertificate type.
  594. ASN.1 notation:
  595. CHOICE {
  596. [identifier1] Type1,
  597. ...,
  598. [identifiern] Typen }
  599. where identifier1 , ..., identifiern are optional, distinct
  600. identifiers for the alternatives, and Type1, ..., Typen are
  601. the types of the alternatives. The identifiers are primarily
  602. for documentation; they do not affect values of the type or
  603. their encodings in any way.
  604. The types must have distinct tags. This requirement is
  605. typically satisfied with explicit or implicit tagging on
  606. some of the alternatives.
  607. Example: PKCS #7's ExtendedCertificateOrCertificate type is
  608. a CHOICE type:
  609. ExtendedCertificateOrCertificate ::= CHOICE {
  610. certificate Certificate, -- X.509
  611. extendedCertificate [0] IMPLICIT ExtendedCertificate
  612. }
  613. Here the identifiers for the alternatives are certificate
  614. and extendedCertificate, and the types of the alternatives
  615. are Certificate and [0] IMPLICIT ExtendedCertificate.
  616. BER encoding. Same as the BER encoding of the chosen
  617. alternative. The fact that the alternatives have distinct
  618. tags makes it possible to distinguish between their BER
  619. encodings.
  620. Example: The identifier octets for the BER encoding are 30
  621. if the chosen alternative is certificate, and a0 if the
  622. chosen alternative is extendedCertificate.
  623. DER encoding. Same as the DER encoding of the chosen
  624. alternative.
  625. 5.6 IA5String
  626. The IA5String type denotes an arbtrary string of IA5
  627. characters. IA5 stands for International Alphabet 5, which
  628. is the same as ASCII. The character set includes non-
  629. printing control characters. An IA5String value can have any
  630. length, including zero. This type is a string type.
  631. The IA5String type is used in PKCS #9's electronic-mail
  632. address, unstructured-name, and unstructured-address
  633. attributes.
  634. ASN.1 notation:
  635. IA5String
  636. BER encoding. Primitive or constructed. In a primitive
  637. encoding, the contents octets give the characters in the IA5
  638. string, encoded in ASCII. In a constructed encoding, the
  639. contents octets give the concatenation of the BER encodings
  640. of consecutive substrings of the IA5 string.
  641. Example: The BER encoding of the IA5String value
  642. "test1@rsa.com" can be any of the following, among others,
  643. depending on the form of length octets and whether the
  644. encoding is primitive or constructed:
  645. 16 0d 74 65 73 74 31 40 72 73 61 2e 63 6f 6d DER encoding
  646. 16 81 0d long form of length octets
  647. 74 65 73 74 31 40 72 73 61 2e 63 6f 6d
  648. 36 13 constructed encoding: "test1" + "@" + "rsa.com"
  649. 16 05 74 65 73 74 31
  650. 16 01 40
  651. 16 07 72 73 61 2e 63 6f 6d
  652. DER encoding. Primitive. Contents octets are as for a
  653. primitive BER encoding.
  654. Example: The DER encoding of the IA5String value
  655. "test1@rsa.com" is
  656. 16 0d 74 65 73 74 31 40 72 73 61 2e 63 6f 6d
  657. 5.7 INTEGER
  658. The INTEGER type denotes an arbitrary integer. INTEGER
  659. values can be positive, negative, or zero, and can have any
  660. magnitude.
  661. The INTEGER type is used for version numbers throughout
  662. PKCS, cryptographic values such as modulus, exponent, and
  663. primes in PKCS #1's RSAPublicKey and RSAPrivateKey types and
  664. PKCS #3's DHParameter type, a message-digest iteration count
  665. in PKCS #5's PBEParameter type, and version numbers and
  666. serial numbers in X.509's Certificate type.
  667. ASN.1 notation:
  668. INTEGER [{ identifier1(value1) ... identifiern(valuen) }]
  669. where identifier1, ..., identifiern are optional distinct
  670. identifiers and value1, ..., valuen are optional integer
  671. values. The identifiers, when present, are associated with
  672. values of the type.
  673. Example: X.509's Version type is an INTEGER type with
  674. identified values:
  675. Version ::= INTEGER { v1988(0) }
  676. The identifier v1988 is associated with the value 0. X.509's
  677. Certificate type uses the identifier v1988 to give a default
  678. value of 0 for the version component:
  679. Certificate ::= ...
  680. version Version DEFAULT v1988,
  681. ...
  682. BER encoding. Primitive. Contents octets give the value of
  683. the integer, base 256, in two's complement form, most
  684. significant digit first, with the minimum number of octets.
  685. The value 0 is encoded as a single 00 octet.
  686. Some example BER encodings (which also happen to be DER
  687. encodings) are given in Table 3.
  688. Integer BER encoding
  689. value
  690. 0 02 01 00
  691. 127 02 01 7F
  692. 128 02 02 00 80
  693. 256 02 02 01 00
  694. -128 02 01 80
  695. -129 02 02 FF 7F
  696. Table 3. Example BER encodings of INTEGER values.
  697. DER encoding. Primitive. Contents octets are as for a
  698. primitive BER encoding.
  699. 5.8 NULL
  700. The NULL type denotes a null value.
  701. The NULL type is used for algorithm parameters in several
  702. places in PKCS.
  703. ASN.1 notation:
  704. NULL
  705. BER encoding. Primitive. Contents octets are empty.
  706. Example: The BER encoding of a NULL value can be either of
  707. the following, as well as others, depending on the form of
  708. the length octets:
  709. 05 00
  710. 05 81 00
  711. DER encoding. Primitive. Contents octets are empty; the DER
  712. encoding of a NULL value is always 05 00.
  713. 5.9 OBJECT IDENTIFIER
  714. The OBJECT IDENTIFIER type denotes an object identifier, a
  715. sequence of integer components that identifies an object
  716. such as an algorithm, an attribute type, or perhaps a
  717. registration authority that defines other object
  718. identifiers. An OBJECT IDENTIFIER value can have any number
  719. of components, and components can generally have any
  720. nonnegative value. This type is a non-string type.
  721. OBJECT IDENTIFIER values are given meanings by registration
  722. authorities. Each registration authority is responsible for
  723. all sequences of components beginning with a given sequence.
  724. A registration authority typically delegates responsibility
  725. for subsets of the sequences in its domain to other
  726. registration authorities, or for particular types of object.
  727. There are always at least two components.
  728. The OBJECT IDENTIFIER type is used to identify content in
  729. PKCS #7's ContentInfo type, to identify algorithms in
  730. X.509's AlgorithmIdentifier type, and to identify attributes
  731. in X.501's Attribute and AttributeValueAssertion types. The
  732. Attribute type is used by PKCS #6, #7, #8, #9, and #10, and
  733. the AttributeValueAssertion type is used in X.501
  734. distinguished names. OBJECT IDENTIFIER values are defined
  735. throughout PKCS.
  736. ASN.1 notation:
  737. OBJECT IDENTIFIER
  738. The ASN.1 notation for values of the OBJECT IDENTIFIER type
  739. is
  740. { [identifier] component1 ... componentn }
  741. componenti = identifieri | identifieri (valuei) | valuei
  742. where identifier, identifier1, ..., identifiern are
  743. identifiers, and value1, ..., valuen are optional integer
  744. values.
  745. The form without identifier is the "complete" value with all
  746. its components; the form with identifier abbreviates the
  747. beginning components with another object identifier value.
  748. The identifiers identifier1, ..., identifiern are intended
  749. primarily for documentation, but they must correspond to the
  750. integer value when both are present. These identifiers can
  751. appear without integer values only if they are among a small
  752. set of identifiers defined in X.208.
  753. Example: The following values both refer to the object
  754. identifier assigned to RSA Data Security, Inc.:
  755. { iso(1) member-body(2) 840 113549 }
  756. { 1 2 840 113549 }
  757. (In this example, which gives ASN.1 value notation, the
  758. object identifier values are decimal, not hexadecimal.)
  759. Table 4 gives some other object identifier values and their
  760. meanings.
  761. Object identifier value Meaning
  762. { 1 2 } ISO member bodies
  763. { 1 2 840 } US (ANSI)
  764. { 1 2 840 113549 } RSA Data Security, Inc.
  765. { 1 2 840 113549 1 } RSA Data Security, Inc. PKCS
  766. { 2 5 } directory services (X.500)
  767. { 2 5 8 } directory services-algorithms
  768. Table 4. Some object identifier values and their meanings.
  769. BER encoding. Primitive. Contents octets are as follows,
  770. where value1, ..., valuen denote the integer values of the
  771. components in the complete object identifier:
  772. 1. The first octet has value 40 * value1 + value2.
  773. (This is unambiguous, since value1 is limited to
  774. values 0, 1, and 2; value2 is limited to the range
  775. 0 to 39 when value1 is 0 or 1; and, according to
  776. X.208, n is always at least 2.)
  777. 2. The following octets, if any, encode value3, ...,
  778. valuen. Each value is encoded base 128, most
  779. significant digit first, with as few digits as
  780. possible, and the most significant bit of each
  781. octet except the last in the value's encoding set
  782. to "1."
  783. Example: The first octet of the BER encoding of RSA Data
  784. Security, Inc.'s object identifier is 40 * 1 + 2 = 42 =
  785. 2a16. The encoding of 840 = 6 * 128 + 4816 is 86 48 and the
  786. encoding of 113549 = 6 * 1282 + 7716 * 128 + d16 is 86 f7
  787. 0d. This leads to the following BER encoding:
  788. 06 06 2a 86 48 86 f7 0d
  789. DER encoding. Primitive. Contents octets are as for a
  790. primitive BER encoding.
  791. 5.10 OCTET STRING
  792. The OCTET STRING type denotes an arbitrary string of octets
  793. (eight-bit values). An OCTET STRING value can have any
  794. length, including zero. This type is a string type.
  795. The OCTET STRING type is used for salt values in PKCS #5's
  796. PBEParameter type, for message digests, encrypted message
  797. digests, and encrypted content in PKCS #7, and for private
  798. keys and encrypted private keys in PKCS #8.
  799. ASN.1 notation:
  800. OCTET STRING [SIZE ({size | size1..size2})]
  801. where size, size1, and size2 are optional size constraints.
  802. In the OCTET STRING SIZE (size) form, the octet string must
  803. have size octets. In the OCTET STRING SIZE (size1..size2)
  804. form, the octet string must have between size1 and size2
  805. octets. In the OCTET STRING form, the octet string can have
  806. any size.
  807. Example: PKCS #5's PBEParameter type has a component of type
  808. OCTET STRING:
  809. PBEParameter ::= SEQUENCE {
  810. salt OCTET STRING SIZE(8),
  811. iterationCount INTEGER }
  812. Here the size of the salt component is always eight octets.
  813. BER encoding. Primitive or constructed. In a primitive
  814. encoding, the contents octets give the value of the octet
  815. string, first octet to last octet. In a constructed
  816. encoding, the contents octets give the concatenation of the
  817. BER encodings of substrings of the OCTET STRING value.
  818. Example: The BER encoding of the OCTET STRING value 01 23 45
  819. 67 89 ab cd ef can be any of the following, among others,
  820. depending on the form of length octets and whether the
  821. encoding is primitive or constructed:
  822. 04 08 01 23 45 67 89 ab cd ef DER encoding
  823. 04 81 08 01 23 45 67 89 ab cd ef long form of length octets
  824. 24 0c constructed encoding: 01 ... 67 + 89 ... ef
  825. 04 04 01 23 45 67
  826. 04 04 89 ab cd ef
  827. DER encoding. Primitive. Contents octets are as for a
  828. primitive BER encoding.
  829. Example: The BER encoding of the OCTET STRING value 01 23 45
  830. 67 89 ab cd ef is
  831. 04 08 01 23 45 67 89 ab cd ef
  832. 5.11 PrintableString
  833. The PrintableString type denotes an arbitrary string of
  834. printable characters from the following character set:
  835. A, B, ..., Z
  836. a, b, ..., z
  837. 0, 1, ..., 9
  838. (space) ' ( ) + , - . / : = ?
  839. This type is a string type.
  840. The PrintableString type is used in PKCS #9's challenge-
  841. password and unstructuerd-address attributes, and in several
  842. X.521 distinguished names attributes.
  843. ASN.1 notation:
  844. PrintableString
  845. BER encoding. Primitive or constructed. In a primitive
  846. encoding, the contents octets give the characters in the
  847. printable string, encoded in ASCII. In a constructed
  848. encoding, the contents octets give the concatenation of the
  849. BER encodings of consecutive substrings of the string.
  850. Example: The BER encoding of the PrintableString value "Test
  851. User 1" can be any of the following, among others, depending
  852. on the form of length octets and whether the encoding is
  853. primitive or constructed:
  854. 13 0b 54 65 73 74 20 55 73 65 72 20 31 DER encoding
  855. 13 81 0b long form of length octets
  856. 54 65 73 74 20 55 73 65 72 20 31
  857. 33 0f constructed encoding: "Test " + "User 1"
  858. 13 05 54 65 73 74 20
  859. 13 06 55 73 65 72 20 31
  860. DER encoding. Primitive. Contents octets are as for a
  861. primitive BER encoding.
  862. Example: The DER encoding of the PrintableString value "Test
  863. User 1" is
  864. 13 0b 54 65 73 74 20 55 73 65 72 20 31
  865. 5.12 SEQUENCE
  866. The SEQUENCE type denotes an ordered collection of one or
  867. more types.
  868. The SEQUENCE type is used throughout PKCS and related
  869. standards.
  870. ASN.1 notation:
  871. SEQUENCE {
  872. [identifier1] Type1 [{OPTIONAL | DEFAULT value1}],
  873. ...,
  874. [identifiern] Typen [{OPTIONAL | DEFAULT valuen}]}
  875. where identifier1 , ..., identifiern are optional, distinct
  876. identifiers for the components, Type1, ..., Typen are the
  877. types of the components, and value1, ..., valuen are optional
  878. default values for the components. The identifiers are
  879. primarily for documentation; they do not affect values of
  880. the type or their encodings in any way.
  881. The OPTIONAL qualifier indicates that the value of a
  882. component is optional and need not be present in the
  883. sequence. The DEFAULT qualifier also indicates that the
  884. value of a component is optional, and assigns a default
  885. value to the component when the component is absent.
  886. The types of any consecutive series of components with the
  887. OPTIONAL or DEFAULT qualifier, as well as of any component
  888. immediately following that series, must have distinct tags.
  889. This requirement is typically satisfied with explicit or
  890. implicit tagging on some of the components.
  891. Example: X.509's Validity type is a SEQUENCE type with two
  892. components:
  893. Validity ::= SEQUENCE {
  894. start UTCTime,
  895. end UTCTime }
  896. Here the identifiers for the components are start and end,
  897. and the types of the components are both UTCTime.
  898. BER encoding. Constructed. Contents octets are the
  899. concatenation of the BER encodings of the values of the
  900. components of the sequence, in order of definition, with the
  901. following rules for components with the OPTIONAL and DEFAULT
  902. qualifiers:
  903. o if the value of a component with the OPTIONAL or
  904. DEFAULT qualifier is absent from the sequence,
  905. then the encoding of that component is not
  906. included in the contents octets
  907. o if the value of a component with the DEFAULT
  908. qualifier is the default value, then the encoding
  909. of that component may or may not be included in
  910. the contents octets
  911. DER encoding. Constructed. Contents octets are the same as
  912. the BER encoding, except that if the value of a component
  913. with the DEFAULT qualifier is the default value, the
  914. encoding of that component is not included in the contents
  915. octets.
  916. 5.13 SEQUENCE OF
  917. The SEQUENCE OF type denotes an ordered collection of zero
  918. or more occurrences of a given type.
  919. The SEQUENCE OF type is used in X.501 distinguished names.
  920. ASN.1 notation:
  921. SEQUENCE OF Type
  922. where Type is a type.
  923. Example: X.501's RDNSequence type consists of zero or more
  924. occurences of the RelativeDistinguishedName type, most
  925. significant occurrence first:
  926. RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
  927. BER encoding. Constructed. Contents octets are the
  928. concatenation of the BER encodings of the values of the
  929. occurrences in the collection, in order of occurence.
  930. DER encoding. Constructed. Contents octets are the
  931. concatenation of the DER encodings of the values of the
  932. occurrences in the collection, in order of occurence.
  933. 5.14 SET
  934. The SET type denotes an unordered collection of one or more
  935. types.
  936. The SET type is not used in PKCS.
  937. ASN.1 notation:
  938. SET {
  939. [identifier1] Type1 [{OPTIONAL | DEFAULT value1}],
  940. ...,
  941. [identifiern] Typen [{OPTIONAL | DEFAULT valuen}]}
  942. where identifier1, ..., identifiern are optional, distinct
  943. identifiers for the components, Type1, ..., Typen are the
  944. types of the components, and value1, ..., valuen are
  945. optional default values for the components. The identifiers
  946. are primarily for documentation; they do not affect values
  947. of the type or their encodings in any way.
  948. The OPTIONAL qualifier indicates that the value of a
  949. component is optional and need not be present in the set.
  950. The DEFAULT qualifier also indicates that the value of a
  951. component is optional, and assigns a default value to the
  952. component when the component is absent.
  953. The types must have distinct tags. This requirement is
  954. typically satisfied with explicit or implicit tagging on
  955. some of the components.
  956. BER encoding. Constructed. Contents octets are the
  957. concatenation of the BER encodings of the values of the
  958. components of the set, in any order, with the following
  959. rules for components with the OPTIONAL and DEFAULT
  960. qualifiers:
  961. o if the value of a component with the OPTIONAL or
  962. DEFAULT qualifier is absent from the set, then the
  963. encoding of that component is not included in the
  964. contents octets
  965. o if the value of a component with the DEFAULT
  966. qualifier is the default value, then the encoding
  967. of that component may or may not be included in
  968. the contents octets
  969. DER encoding. Constructed. Contents octets are the same as
  970. for the BER encoding, except that:
  971. 1. If the value of a component with the DEFAULT
  972. qualifier is the default value, the encoding of
  973. that component is not included.
  974. 2. There is an order to the components, namely
  975. ascending order by tag.
  976. 5.15 SET OF
  977. The SET OF type denotes an unordered collection of zero or
  978. more occurrences of a given type.
  979. The SET OF type is used for sets of attributes in PKCS #6,
  980. #7, #8, #9 and #10, for sets of message-digest algorithm
  981. identifiers, signer information, and recipient information
  982. in PKCS #7, and in X.501 distinguished names.
  983. ASN.1 notation:
  984. SET OF Type
  985. where Type is a type.
  986. Example: X.501's RelativeDistinguishedName type consists of
  987. zero or more occurrences of the AttributeValueAssertion
  988. type, where the order is unimportant:
  989. RelativeDistinguishedName ::=
  990. SET OF AttributeValueAssertion
  991. BER encoding. Constructed. Contents octets are the
  992. concatenation of the BER encodings of the values of the
  993. occurrences in the collection, in any order.
  994. DER encoding. Constructed. Contents octets are the same as
  995. for the BER encoding, except that there is an order, namely
  996. ascending lexicographic order of BER encoding. Lexicographic
  997. comparison of two different BER encodings is done as
  998. follows: Logically pad the shorter BER encoding after the
  999. last octet with dummy octets that are smaller in value than
  1000. any normal octet. Scan the BER encodings from left to right
  1001. until a difference is found. The smaller-valued BER encoding
  1002. is the one with the smaller-valued octet at the point of
  1003. difference.
  1004. 5.16 T61String
  1005. The T61String type denotes an arbtrary string of T.61
  1006. characters. T.61 is an eight-bit extension to the ASCII
  1007. character set. Special "escape" sequences specify the
  1008. interpretation of subsequent character values as, for
  1009. example, Japanese; the initial interpretation is Latin. The
  1010. character set includes non-printing control characters. The
  1011. T61String type allows only the Latin and Japanese character
  1012. interepretations, and implementors' agreements for directory
  1013. names exclude control characters [NIST92]. A T61String value
  1014. can have any length, including zero. This type is a string
  1015. type.
  1016. The T61String type is used in PKCS #9's unstructured-address
  1017. and challenge-password attributes, and in several X.521
  1018. attributes.
  1019. ASN.1 notation:
  1020. T61String
  1021. BER encoding. Primitive or constructed. In a primitive
  1022. encoding, the contents octets give the characters in the
  1023. T.61 string, encoded in ASCII. In a constructed encoding,
  1024. the contents octets give the concatenation of the BER
  1025. encodings of consecutive substrings of the T.61 string.
  1026. Example: The BER encoding of the T61String value "cl'es
  1027. publiques" (French for "public keys") can be any of the
  1028. following, among others, depending on the form of length
  1029. octets and whether the encoding is primitive or constructed:
  1030. 14 0f DER encoding
  1031. 63 6c c2 65 73 20 70 75 62 6c 69 71 75 65 73
  1032. 14 81 0f long form of length octets
  1033. 63 6c c2 65 73 20 70 75 62 6c 69 71 75 65 73
  1034. 34 15 constructed encoding: "cl'es" + " " + "publiques"
  1035. 14 05 63 6c c2 65 73
  1036. 14 01 20
  1037. 14 09 70 75 62 6c 69 71 75 65 73
  1038. The eight-bit character c2 is a T.61 prefix that adds an
  1039. acute accent (') to the next character.
  1040. DER encoding. Primitive. Contents octets are as for a
  1041. primitive BER encoding.
  1042. Example: The DER encoding of the T61String value "cl'es
  1043. publiques" is
  1044. 14 0f 63 6c c2 65 73 20 70 75 62 6c 69 71 75 65 73
  1045. 5.17 UTCTime
  1046. The UTCTime type denotes a "coordinated universal time" or
  1047. Greenwich Mean Time (GMT) value. A UTCTime value includes
  1048. the local time precise to either minutes or seconds, and an
  1049. offset from GMT in hours and minutes. It takes any of the
  1050. following forms:
  1051. YYMMDDhhmmZ
  1052. YYMMDDhhmm+hh'mm'
  1053. YYMMDDhhmm-hh'mm'
  1054. YYMMDDhhmmssZ
  1055. YYMMDDhhmmss+hh'mm'
  1056. YYMMDDhhmmss-hh'mm'
  1057. where:
  1058. YY is the least significant two digits of the year
  1059. MM is the month (01 to 12)
  1060. DD is the day (01 to 31)
  1061. hh is the hour (00 to 23)
  1062. mm are the minutes (00 to 59)
  1063. ss are the seconds (00 to 59)
  1064. Z indicates that local time is GMT, + indicates that
  1065. local time is later than GMT, and - indicates that
  1066. local time is earlier than GMT
  1067. hh' is the absolute value of the offset from GMT in
  1068. hours
  1069. mm' is the absolute value of the offset from GMT in
  1070. minutes
  1071. This type is a string type.
  1072. The UTCTime type is used for signing times in PKCS #9's
  1073. signing-time attribute and for certificate validity periods
  1074. in X.509's Validity type.
  1075. ASN.1 notation:
  1076. UTCTime
  1077. BER encoding. Primitive or constructed. In a primitive
  1078. encoding, the contents octets give the characters in the
  1079. string, encoded in ASCII. In a constructed encoding, the
  1080. contents octets give the concatenation of the BER encodings
  1081. of consecutive substrings of the string. (The constructed
  1082. encoding is not particularly interesting, since UTCTime
  1083. values are so short, but the constructed encoding is
  1084. permitted.)
  1085. Example: The time this sentence was originally written was
  1086. 4:45:40 p.m. Pacific Daylight Time on May 6, 1991, which can
  1087. be represented with either of the following UTCTime values,
  1088. among others:
  1089. "910506164540-0700"
  1090. "910506234540Z"
  1091. These values have the following BER encodings, among others:
  1092. 17 0d 39 31 30 35 30 36 32 33 34 35 34 30 5a
  1093. 17 11 39 31 30 35 30 36 31 36 34 35 34 30 2D 30 37 30
  1094. 30
  1095. DER encoding. Primitive. Contents octets are as for a
  1096. primitive BER encoding.
  1097. 6. An example
  1098. This section gives an example of ASN.1 notation and DER
  1099. encoding: the X.501 type Name.
  1100. 6.1 Abstract notation
  1101. This section gives the ASN.1 notation for the X.501 type
  1102. Name.
  1103. Name ::= CHOICE {
  1104. RDNSequence }
  1105. RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
  1106. RelativeDistinguishedName ::=
  1107. SET OF AttributeValueAssertion
  1108. AttributeValueAssertion ::= SEQUENCE {
  1109. AttributeType,
  1110. AttributeValue }
  1111. AttributeType ::= OBJECT IDENTIFIER
  1112. AttributeValue ::= ANY
  1113. The Name type identifies an object in an X.500 directory.
  1114. Name is a CHOICE type consisting of one alternative:
  1115. RDNSequence. (Future revisions of X.500 may have other
  1116. alternatives.)
  1117. The RDNSequence type gives a path through an X.500 directory
  1118. tree starting at the root. RDNSequence is a SEQUENCE OF type
  1119. consisting of zero or more occurences of
  1120. RelativeDistinguishedName.
  1121. The RelativeDistinguishedName type gives a unique name to an
  1122. object relative to the object superior to it in the
  1123. directory tree. RelativeDistinguishedName is a SET OF type
  1124. consisting of zero or more occurrences of
  1125. AttributeValueAssertion.
  1126. The AttributeValueAssertion type assigns a value to some
  1127. attribute of a relative distinguished name, such as country
  1128. name or common name. AttributeValueAssertion is a SEQUENCE
  1129. type consisting of two components, an AttributeType type and
  1130. an AttributeValue type.
  1131. The AttributeType type identifies an attribute by object
  1132. identifier. The AttributeValue type gives an arbitrary
  1133. attribute value. The actual type of the attribute value is
  1134. determined by the attribute type.
  1135. 6.2 DER encoding
  1136. This section gives an example of a DER encoding of a value
  1137. of type Name, working from the bottom up.
  1138. The name is that of the Test User 1 from the PKCS examples
  1139. [Kal93]. The name is represented by the following path:
  1140. (root)
  1141. |
  1142. countryName = "US"
  1143. |
  1144. organizationName = "Example Organization"
  1145. |
  1146. commonName = "Test User 1"
  1147. Each level corresponds to one RelativeDistinguishedName
  1148. value, each of which happens for this name to consist of one
  1149. AttributeValueAssertion value. The AttributeType value is
  1150. before the equals sign, and the AttributeValue value (a
  1151. printable string for the given attribute types) is after the
  1152. equals sign.
  1153. The countryName, organizationName, and commonUnitName are
  1154. attribute types defined in X.520 as:
  1155. attributeType OBJECT IDENTIFIER ::=
  1156. { joint-iso-ccitt(2) ds(5) 4 }
  1157. countryName OBJECT IDENTIFIER ::= { attributeType 6 }
  1158. organizationName OBJECT IDENTIFIER ::=
  1159. { attributeType 10 }
  1160. commonUnitName OBJECT IDENTIFIER ::=
  1161. { attributeType 3 }
  1162. 6.2.1 AttributeType
  1163. The three AttributeType values are OCTET STRING values, so
  1164. their DER encoding follows the primitive, definite-length
  1165. method:
  1166. 06 03 55 04 06 countryName
  1167. 06 03 55 04 0a organizationName
  1168. 06 03 55 04 03 commonName
  1169. The identifier octets follow the low-tag form, since the tag
  1170. is 6 for OBJECT IDENTIFIER. Bits 8 and 7 have value "0,"
  1171. indicating universal class, and bit 6 has value "0,"
  1172. indicating that the encoding is primitive. The length octets
  1173. follow the short form. The contents octets are the
  1174. concatenation of three octet strings derived from
  1175. subidentifiers (in decimal): 40 * 2 + 5 = 85 = 5516; 4; and
  1176. 6, 10, or 3.
  1177. 6.2.2 AttributeValue
  1178. The three AttributeValue values are PrintableString values,
  1179. so their encodings follow the primitive, definite-length
  1180. method:
  1181. 13 02 55 53 "US"
  1182. 13 14 "Example Organization"
  1183. 45 78 61 6d 70 6c 65 20 4f 72 67 61 6e 69 7a 61
  1184. 74 69 6f 6e
  1185. 13 0b "Test User 1"
  1186. 54 65 73 74 20 55 73 65 72 20 31
  1187. The identifier octets follow the low-tag-number form, since
  1188. the tag for PrintableString, 19 (decimal), is between 0 and
  1189. 30. Bits 8 and 7 have value "0" since PrintableString is in
  1190. the universal class. Bit 6 has value "0" since the encoding
  1191. is primitive. The length octets follow the short form, and
  1192. the contents octets are the ASCII representation of the
  1193. attribute value.
  1194. 6.2.3 AttributeValueAssertion
  1195. The three AttributeValueAssertion values are SEQUENCE
  1196. values, so their DER encodings follow the constructed,
  1197. definite-length method:
  1198. 30 09 countryName = "US"
  1199. 06 03 55 04 06
  1200. 13 02 55 53
  1201. 30 1b organizationName = "Example Organizaiton"
  1202. 06 03 55 04 0a
  1203. 13 14 ... 6f 6e
  1204. 30 12 commonName = "Test User 1"
  1205. 06 03 55 04 0b
  1206. 13 0b ... 20 31
  1207. The identifier octets follow the low-tag-number form, since
  1208. the tag for SEQUENCE, 16 (decimal), is between 0 and 30.
  1209. Bits 8 and 7 have value "0" since SEQUENCE is in the
  1210. universal class. Bit 6 has value "1" since the encoding is
  1211. constructed. The length octets follow the short form, and
  1212. the contents octets are the concatenation of the DER
  1213. encodings of the attributeType and attributeValue
  1214. components.
  1215. 6.2.4 RelativeDistinguishedName
  1216. The three RelativeDistinguishedName values are SET OF
  1217. values, so their DER encodings follow the constructed,
  1218. definite-length method:
  1219. 31 0b
  1220. 30 09 ... 55 53
  1221. 31 1d
  1222. 30 1b ... 6f 6e
  1223. 31 14
  1224. 30 12 ... 20 31
  1225. The identifier octets follow the low-tag-number form, since
  1226. the tag for SET OF, 17 (decimal), is between 0 and 30. Bits
  1227. 8 and 7 have value "0" since SET OF is in the universal
  1228. class Bit 6 has value "1" since the encoding is constructed.
  1229. The lengths octets follow the short form, and the contents
  1230. octets are the DER encodings of the respective
  1231. AttributeValueAssertion values, since there is only one
  1232. value in each set.
  1233. 6.2.5 RDNSequence
  1234. The RDNSequence value is a SEQUENCE OF value, so its DER
  1235. encoding follows the constructed, definite-length method:
  1236. 30 42
  1237. 31 0b ... 55 53
  1238. 31 1d ... 6f 6e
  1239. 31 14 ... 20 31
  1240. The identifier octets follow the low-tag-number form, since
  1241. the tag for SEQUENCE OF, 16 (decimal), is between 0 and 30.
  1242. Bits 8 and 7 have value "0" since SEQUENCE OF is in the
  1243. universal class. Bit 6 has value "1" since the encoding is
  1244. constructed. The lengths octets follow the short form, and
  1245. the contents octets are the concatenation of the DER
  1246. encodings of the three RelativeDistinguishedName values, in
  1247. order of occurrence.
  1248. 6.2.6 Name
  1249. The Name value is a CHOICE value, so its DER encoding is the
  1250. same as that of the RDNSequence value:
  1251. 30 42
  1252. 31 0b
  1253. 30 09
  1254. 06 03 55 04 06 attributeType = countryName
  1255. 13 02 55 53 attributeValue = "US"
  1256. 31 1d
  1257. 30 1b
  1258. 06 03 55 04 0a attributeType = organizationName
  1259. 13 14 attributeValue = "Example Organization"
  1260. 45 78 61 6d 70 6c 65 20 4f 72 67 61 6e 69 7a 61
  1261. 74 69 6f 6e
  1262. 31 14
  1263. 30 12
  1264. 06 03 55 04 03 attributeType = commonName
  1265. 13 0b attributeValue = "Test User 1"
  1266. 54 65 73 74 20 55 73 65 72 20 31
  1267. References
  1268. PKCS #1 RSA Laboratories. PKCS #1: RSA Encryption
  1269. Standard. Version 1.5, November 1993.
  1270. PKCS #3 RSA Laboratories. PKCS #3: Diffie-Hellman Key-
  1271. Agreement Standard. Version 1.4, November 1993.
  1272. PKCS #5 RSA Laboratories. PKCS #5: Password-Based
  1273. Encryption Standard. Version 1.5, November 1993.
  1274. PKCS #6 RSA Laboratories. PKCS #6: Extended-Certificate
  1275. Syntax Standard. Version 1.5, November 1993.
  1276. PKCS #7 RSA Laboratories. PKCS #7: Cryptographic Message
  1277. Syntax Standard. Version 1.5, November 1993.
  1278. PKCS #8 RSA Laboratories. PKCS #8: Private-Key Information
  1279. Syntax Standard. Version 1.2, November 1993.
  1280. PKCS #9 RSA Laboratories. PKCS #9: Selected Attribute
  1281. Types. Version 1.1, November 1993.
  1282. PKCS #10 RSA Laboratories. PKCS #10: Certification Request
  1283. Syntax Standard. Version 1.0, November 1993.
  1284. X.200 CCITT. Recommendation X.200: Reference Model of
  1285. Open Systems Interconnection for CCITT
  1286. Applications. 1984.
  1287. X.208 CCITT. Recommendation X.208: Specification of
  1288. Abstract Syntax Notation One (ASN.1). 1988.
  1289. X.209 CCITT. Recommendation X.209: Specification of
  1290. Basic Encoding Rules for Abstract Syntax Notation
  1291. One (ASN.1). 1988.
  1292. X.500 CCITT. Recommendation X.500: The
  1293. Directory--Overview of Concepts, Models and
  1294. Services. 1988.
  1295. X.501 CCITT. Recommendation X.501: The Directory--
  1296. Models. 1988.
  1297. X.509 CCITT. Recommendation X.509: The Directory--
  1298. Authentication Framework. 1988.
  1299. X.520 CCITT. Recommendation X.520: The Directory--
  1300. Selected Attribute Types. 1988.
  1301. [Kal93] Burton S. Kaliski Jr. Some Examples of the PKCS
  1302. Standards. RSA Laboratories, November 1993.
  1303. [NIST92] NIST. Special Publication 500-202: Stable
  1304. Implementation Agreements for Open Systems
  1305. Interconnection Protocols. Part 11 (Directory
  1306. Services Protocols). December 1992.
  1307. Revision history
  1308. June 3, 1991 version
  1309. The June 3, 1991 version is part of the initial public
  1310. release of PKCS. It was published as NIST/OSI Implementors'
  1311. Workshop document SEC-SIG-91-17.
  1312. November 1, 1993 version
  1313. The November 1, 1993 version incorporates several editorial
  1314. changes, including the addition of a revision history. It is
  1315. updated to be consistent with the following versions of the
  1316. PKCS documents:
  1317. PKCS #1: RSA Encryption Standard. Version 1.5, November
  1318. 1993.
  1319. PKCS #3: Diffie-Hellman Key-Agreement Standard. Version
  1320. 1.4, November 1993.
  1321. PKCS #5: Password-Based Encryption Standard. Version
  1322. 1.5, November 1993.
  1323. PKCS #6: Extended-Certificate Syntax Standard. Version
  1324. 1.5, November 1993.
  1325. PKCS #7: Cryptographic Message Syntax Standard. Version
  1326. 1.5, November 1993.
  1327. PKCS #8: Private-Key Information Syntax Standard.
  1328. Version 1.2, November 1993.
  1329. PKCS #9: Selected Attribute Types. Version 1.1,
  1330. November 1993.
  1331. PKCS #10: Certification Request Syntax Standard.
  1332. Version 1.0, November 1993.
  1333. The following substantive changes were made:
  1334. Section 5: Description of T61String type is added.
  1335. Section 6: Names are changed, consistent with other
  1336. PKCS examples.
  1337. Author's address
  1338. Burton S. Kaliski Jr., Ph.D.
  1339. Chief Scientist
  1340. RSA Laboratories (415) 595-7703
  1341. 100 Marine Parkway (415) 595-4126 (fax)
  1342. Redwood City, CA 94065 USA burt@rsa.com