* Convert signature parameters object to ASN.1 * * @param {string} oid Signature algorithm OID * @param {any} params The signature parameters object * @return ASN.1 object representing signature parameters
(oid, params)
| 96 | * @return ASN.1 object representing signature parameters |
| 97 | */ |
| 98 | function _signatureParametersToAsn1(oid, params) { |
| 99 | const parts = [] |
| 100 | |
| 101 | switch (oid) { |
| 102 | case oids['RSASSA-PSS']: |
| 103 | if (params.hash.algorithmOid !== undefined) { |
| 104 | parts.push( |
| 105 | asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [ |
| 106 | asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [ |
| 107 | asn1.create( |
| 108 | asn1.Class.UNIVERSAL, |
| 109 | asn1.Type.OID, |
| 110 | false, |
| 111 | asn1.oidToDer(params.hash.algorithmOid).getBytes() |
| 112 | ), |
| 113 | asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '') |
| 114 | ]) |
| 115 | ]) |
| 116 | ) |
| 117 | } |
| 118 | |
| 119 | if (params.mgf.algorithmOid !== undefined) { |
| 120 | parts.push( |
| 121 | asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, [ |
| 122 | asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [ |
| 123 | asn1.create( |
| 124 | asn1.Class.UNIVERSAL, |
| 125 | asn1.Type.OID, |
| 126 | false, |
| 127 | asn1.oidToDer(params.mgf.algorithmOid).getBytes() |
| 128 | ), |
| 129 | asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [ |
| 130 | asn1.create( |
| 131 | asn1.Class.UNIVERSAL, |
| 132 | asn1.Type.OID, |
| 133 | false, |
| 134 | asn1.oidToDer(params.mgf.hash.algorithmOid).getBytes() |
| 135 | ), |
| 136 | asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '') |
| 137 | ]) |
| 138 | ]) |
| 139 | ]) |
| 140 | ) |
| 141 | } |
| 142 | |
| 143 | if (params.saltLength !== undefined) { |
| 144 | parts.push( |
| 145 | asn1.create(asn1.Class.CONTEXT_SPECIFIC, 2, true, [ |
| 146 | asn1.create( |
| 147 | asn1.Class.UNIVERSAL, |
| 148 | asn1.Type.INTEGER, |
| 149 | false, |
| 150 | asn1.integerToDer(params.saltLength).getBytes() |
| 151 | ) |
| 152 | ]) |
| 153 | ) |
| 154 | } |
| 155 |