Class Index | File Index

Classes


Class KJUR.asn1.cms.CMSParser

CMS SignedData parser class
Defined in: asn1cms-1.0.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
class for parsing CMS SignedData
This is an ASN.1 parser for CMS SignedData defined in RFC 5652 Cryptographic Message Syntax (CMS).
Method Summary
Method Attributes Method Name and Description
 
parse ASN.1 Attributes
This method parses ASN.1 Attribute defined in RFC 5652 section 5.
 
parse ASN.1 SET OF Attributes
This method parses ASN.1 SET OF Attribute defined in RFC 5652 section 5.
 
parse ASN.1 CertificateSet
This method parses ASN.1 IssuerSerial defined in RFC 5652 CMS section 10.2.3 and section 10.2.2.
 
parse ASN.1 ContentInfo with SignedData
This method parses ASN.1 ContentInfo with SignedData defined in RFC 5652 section 3 and section 5.
 
parse ASN.1 EncapsulatedContentInfo
This method parses ASN.1 SignedData defined in RFC 5652 section 5.
 
parse ASN.1 ESSCertID
This method parses ASN.1 ESSCertID defined in RFC 5035 section 6.
 
parse ASN.1 ESSCertIDv2
This method parses ASN.1 ESSCertIDv2 defined in RFC 5035 section 4.
 
parse ASN.1 DigestAlgorithmIdentifiers
This method parses ASN.1 SignedData defined in RFC 5652 section 5.1.
 
parse ASN.1 IssuerAndSerialNumber
This method parses ASN.1 IssuerAndSerialNumber defined in RFC 5652 section 5.
 
parse ASN.1 IssuerSerial
This method parses ASN.1 IssuerSerial defined in RFC 5035 section 6.
 
parse ASN.1 SignedData
This method parses ASN.1 SignedData defined in RFC 5652 section 5.
 
parse ASN.1 SignerIdentifier
This method parses ASN.1 SignerIdentifier defined in RFC 5652 section 5.
 
parse ASN.1 SignerInfo
This method parses ASN.1 SignerInfos defined in RFC 5652 section 5.
 
parse ASN.1 SignerInfos
This method parses ASN.1 SignerInfos defined in RFC 5652 section 5.
 
set ContentType attribute
This sets an attribute as ContentType defined in RFC 5652 section 5.
 
set MessageDigest attribute
This sets an attribute as SigningTime defined in RFC 5652 section 5.
 
set SignaturePolicyIdentifier attribute
This sets an attribute as SignaturePolicyIdentifier defined in RFC 5126 CAdES section 5.8.1.
 
set SigningCertificate attribute
This sets an attribute as SigningCertificate defined in RFC 5035 section 5.
 
set SigningCertificateV2 attribute
This sets an attribute as SigningCertificateV2 defined in RFC 5035 section 3.
 
set SigningTime attribute
This sets an attribute as SigningTime defined in RFC 5652 section 5.
Class Detail
KJUR.asn1.cms.CMSParser()
class for parsing CMS SignedData
This is an ASN.1 parser for CMS SignedData defined in RFC 5652 Cryptographic Message Syntax (CMS).
ContentInfo ::= SEQUENCE {
   contentType ContentType,
   content [0] EXPLICIT ANY DEFINED BY contentType }
ContentType ::= OBJECT IDENTIFIER
SignedData ::= SEQUENCE {
   version CMSVersion,
   digestAlgorithms DigestAlgorithmIdentifiers,
   encapContentInfo EncapsulatedContentInfo,
   certificates [0] IMPLICIT CertificateSet OPTIONAL,
   crls [1] IMPLICIT RevocationInfoChoices OPTIONAL,
   signerInfos SignerInfos }
SignerInfos ::= SET OF SignerInfo
CertificateSet ::= SET OF CertificateChoices
DigestAlgorithmIdentifiers ::= SET OF DigestAlgorithmIdentifier
CertificateSet ::= SET OF CertificateChoices
RevocationInfoChoices ::= SET OF RevocationInfoChoice
Since:
jsrsasign 10.1.0 asn1cms 2.0.1
Method Detail
{Array} getAttribute(h)
parse ASN.1 Attributes
This method parses ASN.1 Attribute defined in RFC 5652 section 5. Following attribute type are supported in the latest version:
parser = new KJUR.asn1.cms.CMSParser();
parser.getAttribute("30...") →
{attr: "contentType", type: "tstinfo"}
Parameters:
{String} h
hexadecimal string of ASN.1 Attribute
Returns:
{Array} array of JSON object of Attribute parameter
See:
KJUR.asn1.cms.SignerInfo
KJUR.asn1.cms.CMSParser#getAttributeList

{Array} getAttributeList(h)
parse ASN.1 SET OF Attributes
This method parses ASN.1 SET OF Attribute defined in RFC 5652 section 5. This can be used for SignedAttributes and UnsignedAttributes.
parser = new KJUR.asn1.cms.CMSParser();
parser.getAttributeList("30...") →
[{attr: "contentType", type: "tstinfo"},
 {attr: "messageDigest", hex: "1234abcd..."}]
Parameters:
{String} h
hexadecimal string of ASN.1 SET OF Attribute
Returns:
{Array} array of JSON object of Attribute parameter
See:
KJUR.asn1.cms.SignerInfo
KJUR.asn1.cms.CMSParser#getAttribute

{Array} getCertificateSet(h)
parse ASN.1 CertificateSet
This method parses ASN.1 IssuerSerial defined in RFC 5652 CMS section 10.2.3 and section 10.2.2.
CertificateSet ::= SET OF CertificateChoices
CertificateChoices ::= CHOICE {
  certificate Certificate,
  extendedCertificate [0] IMPLICIT ExtendedCertificate, -- Obsolete
  v1AttrCert [1] IMPLICIT AttributeCertificateV1,       -- Obsolete
  v2AttrCert [2] IMPLICIT AttributeCertificateV2,
  other [3] IMPLICIT OtherCertificateFormat }
OtherCertificateFormat ::= SEQUENCE {
  otherCertFormat OBJECT IDENTIFIER,
  otherCert ANY DEFINED BY otherCertFormat }
Currently only "certificate" is supported in CertificateChoices.
parser = new KJUR.asn1.cms.CMSParser();
parser.getCertificateSet("a0...") →
[ "-----BEGIN CERTIFICATE...", ... ]
Parameters:
{String} h
hexadecimal string of ASN.1 CertificateSet
Returns:
{Array} array of JSON object of CertificateSet parameter
See:
KJUR.asn1.cms.CertificateSet

{Array} getCMSSignedData(h)
parse ASN.1 ContentInfo with SignedData
This method parses ASN.1 ContentInfo with SignedData defined in RFC 5652 section 3 and section 5. The result parameter can be passed to KJUR.asn1.cms.SignedData constructor.
parser = new KJUR.asn1.cms.CMSParser();
parser.getCMSSignedData("30...") →
{
  version: 1,
  hashalgs: ["sha1"],
  econtent: {
    type: "data",
    content: {hex:"616161"}
  },
  certs: [PEM1,...],
  sinfos: [{
    version: 1,
    id: {type:'isssn',issuer:{str:'/C=US/O=T1'},serial:{int: 1}},
    hashalg: "sha1",
    sattrs: {array: [{
      attr: "contentType",
      type: '1.2.840.113549.1.7.1'
    },{
      attr: "messageDigest",
      hex: 'abcd'
    }]},
    sigalg: "SHA1withRSA",
    sighex: "1234abcd..."
  }]
}
Parameters:
{String} h
hexadecimal string of ASN.1 ContentInfo with SignedData
Returns:
{Array} array of JSON object of SignedData parameter
See:
KJUR.asn1.cms.SignedData
KJUR.asn1.cms.CMSParser#getSignedData

{Array} getEContent(h)
parse ASN.1 EncapsulatedContentInfo
This method parses ASN.1 SignedData defined in RFC 5652 section 5. The result parameter can be passed to KJUR.asn1.cms.EncapsulatedContentInfo constructor.
parser = new KJUR.asn1.cms.CMSParser();
parser.getEContent("30...") →
{type: "tstinfo", content: {hex: "30..."}}
Parameters:
{String} h
hexadecimal string of ASN.1 EncapsulatedContentInfo
Returns:
{Array} array of JSON object of EncapsulatedContentInfo parameter
See:
KJUR.asn1.cms.EncapsulatedContentInfo
KJUR.asn1.cms.CMSParser#getSignedData

{Array} getESSCertID(h)
parse ASN.1 ESSCertID
This method parses ASN.1 ESSCertID defined in RFC 5035 section 6.
ESSCertID ::= SEQUENCE {
   certHash Hash,
   issuerSerial IssuerSerial OPTIONAL }
IssuerSerial ::= SEQUENCE {
   issuer GeneralNames,
   serialNumber CertificateSerialNumber }
parser = new KJUR.asn1.cms.CMSParser();
parser.getESSCertID("30...") →
{ hash: "12ab...",
  issuer: {
    array: [[{type:"C",value:"JP",ds:"prn"}],...],
    str: "/C=JP/O=T1"
  },
  serial: {hex: "12ab..."} }
Parameters:
{String} h
hexadecimal string of ASN.1 ESSCertID
Returns:
{Array} array of JSON object of ESSCertID parameter
See:
KJUR.asn1.cms.ESSCertID

{Array} getESSCertIDv2(h)
parse ASN.1 ESSCertIDv2
This method parses ASN.1 ESSCertIDv2 defined in RFC 5035 section 4.
ESSCertIDv2 ::=  SEQUENCE {
   hashAlgorithm           AlgorithmIdentifier
                           DEFAULT {algorithm id-sha256},
   certHash                Hash,
   issuerSerial            IssuerSerial OPTIONAL }
Hash ::= OCTET STRING
IssuerSerial ::= SEQUENCE {
   issuer                  GeneralNames,
   serialNumber            CertificateSerialNumber }
parser = new KJUR.asn1.cms.CMSParser();
parser.getESSCertID("30...") →
{
  hash: "3f2d...",
  alg: "sha512",
  issuer: {str: "/C=JP/O=T1"},
  serial: {hex: "12ab..."}
}
Parameters:
{String} h
hexadecimal string of ASN.1 ESSCertIDv2
Since:
jsrsasign 10.1.2 asn1cms 2.0.3
Returns:
{Array} array of JSON object of ESSCertIDv2 parameter
See:
KJUR.asn1.cms.ESSCertIDv2
KJUR.asn1.cms.CMSParser.getESSCertID

{Array} getHashAlgArray(h)
parse ASN.1 DigestAlgorithmIdentifiers
This method parses ASN.1 SignedData defined in RFC 5652 section 5.1.
parser = new KJUR.asn1.cms.CMSParser();
parser.getHashAlgArray("30...") → ["sha256"]
Parameters:
{String} h
hexadecimal string of ASN.1 DigestAlgorithmIdentifiers
Returns:
{Array} array of JSON object of digest algorithm names
See:
KJUR.asn1.cms.SignedData
KJUR.asn1.cms.CMSParser#getSignedData

{Array} getIssuerAndSerialNumber(h)
parse ASN.1 IssuerAndSerialNumber
This method parses ASN.1 IssuerAndSerialNumber defined in RFC 5652 section 5.
parser = new KJUR.asn1.cms.CMSParser();
parser.getIssuerAndSerialNumber("30...") →
{ type: "isssn",
  issuer: {
    array: [[{type:"C",value:"JP",ds:"prn"},...]]
    str: '/C=US/O=T1'
  },
  serial: {int: 1} }
Parameters:
{String} h
hexadecimal string of ASN.1 IssuerAndSerialNumber
Returns:
{Array} array of JSON object of IssuerAndSerialNumber parameter
See:
KJUR.asn1.cms.SignerInfo
KJUR.asn1.cms.CMSParser#getSignedData

{Array} getIssuerSerial(h)
parse ASN.1 IssuerSerial
This method parses ASN.1 IssuerSerial defined in RFC 5035 section 6.
IssuerSerial ::= SEQUENCE {
   issuer GeneralNames,
   serialNumber CertificateSerialNumber }
parser = new KJUR.asn1.cms.CMSParser();
parser.getIssuerSerial("30...") →
{ issuer: {
    array: [[{type:"C",value:"JP",ds:"prn"}],...],
    str: "/C=JP/O=T1",
  },
  serial: {hex: "12ab..."} }
Parameters:
{String} h
hexadecimal string of ASN.1 IssuerSerial
Returns:
{Array} array of JSON object of IssuerSerial parameter
See:
KJUR.asn1.cms.IssuerSerial
KJUR.asn1.x509.X500Name

{Array} getSignedData(h)
parse ASN.1 SignedData
This method parses ASN.1 SignedData defined in RFC 5652 section 5. The result parameter can be passed to KJUR.asn1.cms.SignedData constructor.
parser = new KJUR.asn1.cms.CMSParser();
parser.getSignedData("30...")
Parameters:
{String} h
hexadecimal string of ASN.1 SignedData
Returns:
{Array} array of JSON object of SignedData parameter
See:
KJUR.asn1.cms.SignedData
KJUR.asn1.cms.CMSParser#getSignedData

{Array} getSignerIdentifier(h)
parse ASN.1 SignerIdentifier
This method parses ASN.1 SignerIdentifier defined in RFC 5652 section 5.
parser = new KJUR.asn1.cms.CMSParser();
parser.getSignerIdentifier("30...") →
{ type: "isssn",
  issuer: {
    array: [[{type:"C",value:"JP",ds:"prn"},...]]
    str: '/C=US/O=T1'
  },
  serial: {int: 1} }
Parameters:
{String} h
hexadecimal string of ASN.1 SignerIdentifier
Returns:
{Array} array of JSON object of SignerIdentifier parameter
See:
KJUR.asn1.cms.SignerInfo
KJUR.asn1.cms.SignerIdentifier
KJUR.asn1.cms.CMSParser#getSignedData

{Array} getSignerInfo(h)
parse ASN.1 SignerInfo
This method parses ASN.1 SignerInfos defined in RFC 5652 section 5.
SignerInfo ::= SEQUENCE {
   version CMSVersion,
   sid SignerIdentifier,
   digestAlgorithm DigestAlgorithmIdentifier,
   signedAttrs [0] IMPLICIT SignedAttributes OPTIONAL,
   signatureAlgorithm SignatureAlgorithmIdentifier,
   signature SignatureValue,
   unsignedAttrs [1] IMPLICIT UnsignedAttributes OPTIONAL }
The result parameter can be passed to KJUR.asn1.cms.SignerInfo constructor.
parser = new KJUR.asn1.cms.CMSParser();
parser.getSignerInfos("30...") →
[{
  version: 1,
  id: {type: 'isssn', issuer: {str: '/C=US/O=T1'}, serial: {int: 1}},
  hashalg: "sha1",
  sattrs: {array: [{
    attr: "contentType",
    type: '1.2.840.113549.1.7.1'
  },{
    attr: "messageDigest",
    hex: 'a1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0'
  }]},
  sigalg: "SHA1withRSA",
  sighex: 'b1b2b...'
}]
Parameters:
{String} h
hexadecimal string of ASN.1 SignerInfo
Returns:
{Array} array of JSON object of SignerInfo parameter
See:
KJUR.asn1.cms.SignerInfo
KJUR.asn1.cms.CMSParser#getSignedData

{Array} getSignerInfos(h)
parse ASN.1 SignerInfos
This method parses ASN.1 SignerInfos defined in RFC 5652 section 5.
parser = new KJUR.asn1.cms.CMSParser();
parser.getSignerInfos("30...") →
[{
  version: 1,
  id: {type: 'isssn', issuer: {str: '/C=US/O=T1'}, serial: {int: 1}},
  hashalg: "sha1",
  sattrs: {array: [{
    attr: "contentType",
    type: '1.2.840.113549.1.7.1'
  },{
    attr: "messageDigest",
    hex: 'a1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0'
  }]},
  sigalg: "SHA1withRSA",
  sighex: 'b1b2b...'
}]
Parameters:
{String} h
hexadecimal string of ASN.1 SignerInfos
Returns:
{Array} array of JSON object of SignerInfos parameter
See:
KJUR.asn1.cms.SignerInfos
KJUR.asn1.cms.CMSParser#getSignedData

setContentType(pAttr)
set ContentType attribute
This sets an attribute as ContentType defined in RFC 5652 section 5.
parser = new KJUR.asn1.cms.CMSParser();
pAttr = {
  attr: "contentType"
  valhex: '060b2a864886f70d0109100104'
};
parser.setContentInfo(pAttr);
pAttr → {
  attr: "contentType"
  type: "tstinfo"
}
Parameters:
{Array} pAttr
JSON object of attribute parameter
See:
KJUR.asn1.cms.CMSParser#getAttribute

setMessageDigest(pAttr)
set MessageDigest attribute
This sets an attribute as SigningTime defined in RFC 5652 section 5.
parser = new KJUR.asn1.cms.CMSParser();
pAttr = {
  attr: "messageDigest"
  valhex: '0403123456'
};
parser.setMessageDigest(pAttr);
pAttr → {
  attr: "messageDigest",
  hex: "123456"
}
Parameters:
{Array} pAttr
JSON object of attribute parameter
See:
KJUR.asn1.cms.CMSParser#getAttribute

setSignaturePolicyIdentifier(pAttr)
set SignaturePolicyIdentifier attribute
This sets an attribute as SignaturePolicyIdentifier defined in RFC 5126 CAdES section 5.8.1.
parser = new KJUR.asn1.cms.CMSParser();
pAttr = {
  attr: "signaturePolicyIdentifier"
  valhex: '...'
};
parser.setSignaturePolicyIdentifier(pAttr);
pAttr → {
  attr: "signaturePolicyIdentifier",
  oid: "1.2.3.4.5",
  alg: "sha1",
  hash: "1a2b..."
}
Parameters:
{Array} pAttr
JSON object of attribute parameter
Since:
jsrsasign 10.1.5 asn1cms 2.0.4
See:
KJUR.asn1.cms.CMSParser#getAttribute
KJUR.asn1.cades.SignaturePolicyIdentifier

setSigningCertificate(pAttr)
set SigningCertificate attribute
This sets an attribute as SigningCertificate defined in RFC 5035 section 5.
parser = new KJUR.asn1.cms.CMSParser();
pAttr = {
  attr: "signingCertificate"
  valhex: '...'
};
parser.setSigningCertificate(pAttr);
pAttr → {
  attr: "signingCertificate",
  array: [{
    hash: "123456...",
    issuer: {
      array: [[{type:"C",value:"JP",ds:"prn"},...]],
      str: "/C=JP/O=T1"
    },
    serial: {hex: "123456..."}
  }]
}
Parameters:
{Array} pAttr
JSON object of attribute parameter
See:
KJUR.asn1.cms.CMSParser#getAttribute

setSigningCertificateV2(pAttr)
set SigningCertificateV2 attribute
This sets an attribute as SigningCertificateV2 defined in RFC 5035 section 3.
parser = new KJUR.asn1.cms.CMSParser();
pAttr = {
  attr: "signingCertificateV2"
  valhex: '...'
};
parser.setSigningCertificateV2(pAttr);
pAttr → {
  attr: "signingCertificateV2",
  array: [{
    hash: "123456...",
    alg: "sha256",
    issuer: {
      array: [[{type:"C",value:"JP",ds:"prn"},...]],
      str: "/C=JP/O=T1"
    },
    serial: {hex: "123456..."}
  }]
}
Parameters:
{Array} pAttr
JSON object of attribute parameter
Since:
jsrsasign 10.1.2 asn1cms 2.0.3
See:
KJUR.asn1.cms.CMSParser#getAttribute
KJUR.asn1.cms.CMSParser#getESSCertIDv2
KJUR.asn1.cms.SigningCertificateV2
KJUR.asn1.cms.ESSCertIDv2

setSigningTime(pAttr)
set SigningTime attribute
This sets an attribute as SigningTime defined in RFC 5652 section 5.
parser = new KJUR.asn1.cms.CMSParser();
pAttr = {
  attr: "signingTime"
  valhex: '170d3230313233313233353935395a'
};
parser.setSigningTime(pAttr);
pAttr → {
  attr: "signingTime",
  str: "2012315959Z"
}
Parameters:
{Array} pAttr
JSON object of attribute parameter
See:
KJUR.asn1.cms.CMSParser#getAttribute

© 2012-2023 Kenji Urushima, All rights reserved
Documentation generated by JsDoc Toolkit 2.4.0