TBSCertificate.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * TBSCertificate
  4. *
  5. * PHP version 5
  6. *
  7. * @category File
  8. * @package ASN1
  9. * @author Jim Wigginton <terrafrost@php.net>
  10. * @copyright 2016 Jim Wigginton
  11. * @license http://www.opensource.org/licenses/mit-license.html MIT License
  12. * @link http://phpseclib.sourceforge.net
  13. */
  14. namespace phpseclib\File\ASN1\Maps;
  15. use phpseclib\File\ASN1;
  16. /**
  17. * TBSCertificate
  18. *
  19. * @package ASN1
  20. * @author Jim Wigginton <terrafrost@php.net>
  21. * @access public
  22. */
  23. abstract class TBSCertificate
  24. {
  25. // assert($TBSCertificate['children']['signature'] == $Certificate['children']['signatureAlgorithm'])
  26. const MAP = [
  27. 'type' => ASN1::TYPE_SEQUENCE,
  28. 'children' => [
  29. // technically, default implies optional, but we'll define it as being optional, none-the-less, just to
  30. // reenforce that fact
  31. 'version' => [
  32. 'type' => ASN1::TYPE_INTEGER,
  33. 'constant' => 0,
  34. 'optional' => true,
  35. 'explicit' => true,
  36. 'mapping' => ['v1', 'v2', 'v3'],
  37. 'default' => 'v1'
  38. ],
  39. 'serialNumber' => CertificateSerialNumber::MAP,
  40. 'signature' => AlgorithmIdentifier::MAP,
  41. 'issuer' => Name::MAP,
  42. 'validity' => Validity::MAP,
  43. 'subject' => Name::MAP,
  44. 'subjectPublicKeyInfo' => SubjectPublicKeyInfo::MAP,
  45. // implicit means that the T in the TLV structure is to be rewritten, regardless of the type
  46. 'issuerUniqueID' => [
  47. 'constant' => 1,
  48. 'optional' => true,
  49. 'implicit' => true
  50. ] + UniqueIdentifier::MAP,
  51. 'subjectUniqueID' => [
  52. 'constant' => 2,
  53. 'optional' => true,
  54. 'implicit' => true
  55. ] + UniqueIdentifier::MAP,
  56. // <http://tools.ietf.org/html/rfc2459#page-74> doesn't use the EXPLICIT keyword but if
  57. // it's not IMPLICIT, it's EXPLICIT
  58. 'extensions' => [
  59. 'constant' => 3,
  60. 'optional' => true,
  61. 'explicit' => true
  62. ] + Extensions::MAP
  63. ]
  64. ];
  65. }