-
-
Notifications
You must be signed in to change notification settings - Fork 644
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,457 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -472,16 +472,14 @@ <h1 class="classTitle"> | |
<li>rfc822 - rfc822Name[1] (ex. [email protected])</li> | ||
<li>dns - dNSName[2] (ex. foo.com)</li> | ||
<li>uri - uniformResourceIdentifier[6] (ex. http://foo.com/)</li> | ||
<li>certissuer - directoryName[4] (PEM or hex string of cert)</li> | ||
<li>certsubj - directoryName[4] (PEM or hex string of cert)</li> | ||
</ul> | ||
NOTE: Currently this only supports 'uniformResourceIdentifier'. | ||
<h4>EXAMPLE AND ASN.1 SYNTAX</h4> | ||
|
||
</div> | ||
|
||
|
||
|
||
<pre class="code">var gn = new KJUR.asn1.x509.GeneralName({'uri': 'http://aaa.com/'}); | ||
NOTE1: certissuer and certsubj is supported since asn1x509 1.0.10. | ||
|
||
Here is definition of the ASN.1 syntax: | ||
<pre> | ||
-- NOTE: under the CHOICE, it will always be explicit. | ||
GeneralName ::= CHOICE { | ||
otherName [0] OtherName, | ||
rfc822Name [1] IA5String, | ||
|
@@ -491,7 +489,18 @@ <h4>EXAMPLE AND ASN.1 SYNTAX</h4> | |
ediPartyName [5] EDIPartyName, | ||
uniformResourceIdentifier [6] IA5String, | ||
iPAddress [7] OCTET STRING, | ||
registeredID [8] OBJECT IDENTIFIER }</pre> | ||
registeredID [8] OBJECT IDENTIFIER } | ||
</pre> | ||
|
||
</div> | ||
|
||
|
||
|
||
<pre class="code">gn = new KJUR.asn1.x509.GeneralName({rfc822: '[email protected]'}); | ||
gn = new KJUR.asn1.x509.GeneralName({dns: 'aaa.com'}); | ||
gn = new KJUR.asn1.x509.GeneralName({uri: 'http://aaa.com/'}); | ||
gn = new KJUR.asn1.x509.GeneralName({certissuer: certPEM}); | ||
gn = new KJUR.asn1.x509.GeneralName({certsubj: certPEM});</pre> | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,12 @@ | |
.STRN {color: #393;} | ||
.REGX {color: #339;} | ||
.line {border-right: 1px dotted #666; color: #666; font-style: normal;} | ||
</style></head><body><pre><span class='line'> 1</span> <span class="COMM">/*! x509-1.1.3.js (c) 2012-2014 Kenji Urushima | kjur.github.com/jsrsasign/license | ||
</style></head><body><pre><span class='line'> 1</span> <span class="COMM">/*! x509-1.1.4.js (c) 2012-2014 Kenji Urushima | kjur.github.com/jsrsasign/license | ||
<span class='line'> 2</span> */</span><span class="WHIT"> | ||
<span class='line'> 3</span> </span><span class="COMM">/* | ||
<span class='line'> 4</span> * x509.js - X509 class to read subject public key from certificate. | ||
<span class='line'> 5</span> * | ||
<span class='line'> 6</span> * Copyright (c) 2010-2014 Kenji Urushima ([email protected]) | ||
<span class='line'> 6</span> * Copyright (c) 2010-2015 Kenji Urushima ([email protected]) | ||
<span class='line'> 7</span> * | ||
<span class='line'> 8</span> * This software is licensed under the terms of the MIT License. | ||
<span class='line'> 9</span> * http://kjur.github.com/jsrsasign/license | ||
|
@@ -23,7 +23,7 @@ | |
<span class='line'> 16</span> * @fileOverview | ||
<span class='line'> 17</span> * @name x509-1.1.js | ||
<span class='line'> 18</span> * @author Kenji Urushima [email protected] | ||
<span class='line'> 19</span> * @version x509 1.1.3 (2014-May-17) | ||
<span class='line'> 19</span> * @version x509 1.1.4 (2015-May-14) | ||
<span class='line'> 20</span> * @since jsrsasign 1.x.x | ||
<span class='line'> 21</span> * @license <a href="http://kjur.github.io/jsrsasign/license/">MIT License</a> | ||
<span class='line'> 22</span> */</span><span class="WHIT"> | ||
|
@@ -365,15 +365,46 @@ | |
<span class='line'>358</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">result</span><span class="PUNC">;</span><span class="WHIT"> | ||
<span class='line'>359</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT"> | ||
<span class='line'>360</span> | ||
<span class='line'>361</span> </span><span class="COMM">/* | ||
<span class='line'>362</span> X509.prototype.readCertPEM = _x509_readCertPEM; | ||
<span class='line'>363</span> X509.prototype.readCertPEMWithoutRSAInit = _x509_readCertPEMWithoutRSAInit; | ||
<span class='line'>364</span> X509.prototype.getSerialNumberHex = _x509_getSerialNumberHex; | ||
<span class='line'>365</span> X509.prototype.getIssuerHex = _x509_getIssuerHex; | ||
<span class='line'>366</span> X509.prototype.getSubjectHex = _x509_getSubjectHex; | ||
<span class='line'>367</span> X509.prototype.getIssuerString = _x509_getIssuerString; | ||
<span class='line'>368</span> X509.prototype.getSubjectString = _x509_getSubjectString; | ||
<span class='line'>369</span> X509.prototype.getNotBefore = _x509_getNotBefore; | ||
<span class='line'>370</span> X509.prototype.getNotAfter = _x509_getNotAfter; | ||
<span class='line'>371</span> */</span><span class="WHIT"> | ||
<span class='line'>372</span> </span></pre></body></html> | ||
<span class='line'>361</span> </span><span class="COMM">/** | ||
<span class='line'>362</span> * get position of subjectPublicKeyInfo field from HEX certificate | ||
<span class='line'>363</span> * @name getPublicKeyInfoPosOfCertHEX | ||
<span class='line'>364</span> * @memberOf X509 | ||
<span class='line'>365</span> * @function | ||
<span class='line'>366</span> * @param {String} hCert hexadecimal string of certificate | ||
<span class='line'>367</span> * @return {Integer} position in hexadecimal string | ||
<span class='line'>368</span> * @since x509 1.1.4 | ||
<span class='line'>369</span> * @description | ||
<span class='line'>370</span> * get position for SubjectPublicKeyInfo field in the hexadecimal string of | ||
<span class='line'>371</span> * certificate. | ||
<span class='line'>372</span> */</span><span class="WHIT"> | ||
<span class='line'>373</span> </span><span class="NAME">X509.getPublicKeyInfoPosOfCertHEX</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">hCert</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> | ||
<span class='line'>374</span> </span><span class="WHIT"> </span><span class="COMM">// 1. Certificate ASN.1</span><span class="WHIT"> | ||
<span class='line'>375</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ASN1HEX.getPosArrayOfChildren_AtObj</span><span class="PUNC">(</span><span class="NAME">hCert</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> | ||
<span class='line'>376</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a1.length</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="WHIT"> | ||
<span class='line'>377</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"malformed X.509 certificate PEM (code:001)"</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// not 3 item of seq Cert</span><span class="WHIT"> | ||
<span class='line'>378</span> | ||
<span class='line'>379</span> </span><span class="WHIT"> </span><span class="COMM">// 2. tbsCertificate</span><span class="WHIT"> | ||
<span class='line'>380</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hCert.substr</span><span class="PUNC">(</span><span class="NAME">a1</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"30"</span><span class="PUNC">)</span><span class="WHIT"> | ||
<span class='line'>381</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"malformed X.509 certificate PEM (code:002)"</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// tbsCert not seq </span><span class="WHIT"> | ||
<span class='line'>382</span> | ||
<span class='line'>383</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ASN1HEX.getPosArrayOfChildren_AtObj</span><span class="PUNC">(</span><span class="NAME">hCert</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">a1</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> | ||
<span class='line'>384</span> | ||
<span class='line'>385</span> </span><span class="COMM">// 3. subjectPublicKeyInfo</span><span class="WHIT"> | ||
<span class='line'>386</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a2.length</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NUMB">7</span><span class="PUNC">)</span><span class="WHIT"> | ||
<span class='line'>387</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"malformed X.509 certificate PEM (code:003)"</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// no subjPubKeyInfo</span><span class="WHIT"> | ||
<span class='line'>388</span> </span><span class="WHIT"> | ||
<span class='line'>389</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">a2</span><span class="PUNC">[</span><span class="NUMB">6</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT"> | ||
<span class='line'>390</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT"> | ||
<span class='line'>391</span> | ||
<span class='line'>392</span> </span><span class="COMM">/* | ||
<span class='line'>393</span> X509.prototype.readCertPEM = _x509_readCertPEM; | ||
<span class='line'>394</span> X509.prototype.readCertPEMWithoutRSAInit = _x509_readCertPEMWithoutRSAInit; | ||
<span class='line'>395</span> X509.prototype.getSerialNumberHex = _x509_getSerialNumberHex; | ||
<span class='line'>396</span> X509.prototype.getIssuerHex = _x509_getIssuerHex; | ||
<span class='line'>397</span> X509.prototype.getSubjectHex = _x509_getSubjectHex; | ||
<span class='line'>398</span> X509.prototype.getIssuerString = _x509_getIssuerString; | ||
<span class='line'>399</span> X509.prototype.getSubjectString = _x509_getSubjectString; | ||
<span class='line'>400</span> X509.prototype.getNotBefore = _x509_getNotBefore; | ||
<span class='line'>401</span> X509.prototype.getNotAfter = _x509_getNotAfter; | ||
<span class='line'>402</span> */</span><span class="WHIT"> | ||
<span class='line'>403</span> </span></pre></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/*! asn1x509-1.0.9.js (c) 2013-2014 Kenji Urushima | kjur.github.com/jsrsasign/license | ||
/*! asn1x509-1.0.10.js (c) 2013-2014 Kenji Urushima | kjur.github.com/jsrsasign/license | ||
*/ | ||
/* | ||
* asn1x509.js - ASN.1 DER encoder classes for X.509 certificate | ||
|
@@ -16,7 +16,7 @@ | |
* @fileOverview | ||
* @name asn1x509-1.0.js | ||
* @author Kenji Urushima [email protected] | ||
* @version 1.0.9 (2014-May-17) | ||
* @version 1.0.10 (2014-Jun-09) | ||
* @since jsrsasign 2.1 | ||
* @license <a href="http://kjur.github.io/jsrsasign/license/">MIT License</a> | ||
*/ | ||
|
@@ -1525,12 +1525,14 @@ YAHOO.lang.extend(KJUR.asn1.x509.AlgorithmIdentifier, KJUR.asn1.ASN1Object); | |
* <li>rfc822 - rfc822Name[1] (ex. [email protected])</li> | ||
* <li>dns - dNSName[2] (ex. foo.com)</li> | ||
* <li>uri - uniformResourceIdentifier[6] (ex. http://foo.com/)</li> | ||
* <li>certissuer - directoryName[4] (PEM or hex string of cert)</li> | ||
* <li>certsubj - directoryName[4] (PEM or hex string of cert)</li> | ||
* </ul> | ||
* NOTE: Currently this only supports 'uniformResourceIdentifier'. | ||
* <h4>EXAMPLE AND ASN.1 SYNTAX</h4> | ||
* @example | ||
* var gn = new KJUR.asn1.x509.GeneralName({'uri': 'http://aaa.com/'}); | ||
* NOTE1: certissuer and certsubj is supported since asn1x509 1.0.10. | ||
* | ||
* Here is definition of the ASN.1 syntax: | ||
* <pre> | ||
* -- NOTE: under the CHOICE, it will always be explicit. | ||
* GeneralName ::= CHOICE { | ||
* otherName [0] OtherName, | ||
* rfc822Name [1] IA5String, | ||
|
@@ -1541,33 +1543,82 @@ YAHOO.lang.extend(KJUR.asn1.x509.AlgorithmIdentifier, KJUR.asn1.ASN1Object); | |
* uniformResourceIdentifier [6] IA5String, | ||
* iPAddress [7] OCTET STRING, | ||
* registeredID [8] OBJECT IDENTIFIER } | ||
* </pre> | ||
* | ||
* | ||
* | ||
* @example | ||
* gn = new KJUR.asn1.x509.GeneralName({rfc822: '[email protected]'}); | ||
* gn = new KJUR.asn1.x509.GeneralName({dns: 'aaa.com'}); | ||
* gn = new KJUR.asn1.x509.GeneralName({uri: 'http://aaa.com/'}); | ||
* gn = new KJUR.asn1.x509.GeneralName({certissuer: certPEM}); | ||
* gn = new KJUR.asn1.x509.GeneralName({certsubj: certPEM}); | ||
*/ | ||
KJUR.asn1.x509.GeneralName = function(params) { | ||
KJUR.asn1.x509.GeneralName.superclass.constructor.call(this); | ||
var asn1Obj = null; | ||
var type = null; | ||
var pTag = {'rfc822': '81', 'dns': '82', 'uri': '86'}; | ||
var pTag = {rfc822: '81', dns: '82', dn: 'a4', uri: '86'}; | ||
this.explicit = false; | ||
|
||
this.setByParam = function(params) { | ||
var str = null; | ||
var v = null; | ||
|
||
if (typeof params['rfc822'] != "undefined") { | ||
if (typeof params == "undefined") return; | ||
|
||
if (typeof params.rfc822 != "undefined") { | ||
this.type = 'rfc822'; | ||
v = new KJUR.asn1.DERIA5String({'str': params[this.type]}); | ||
} | ||
if (typeof params['dns'] != "undefined") { | ||
if (typeof params.dns != "undefined") { | ||
this.type = 'dns'; | ||
v = new KJUR.asn1.DERIA5String({'str': params[this.type]}); | ||
} | ||
if (typeof params['uri'] != "undefined") { | ||
if (typeof params.uri != "undefined") { | ||
this.type = 'uri'; | ||
v = new KJUR.asn1.DERIA5String({'str': params[this.type]}); | ||
} | ||
if (typeof params.certissuer != "undefined") { | ||
this.type = 'dn'; | ||
this.explicit = true; | ||
var certStr = params.certissuer; | ||
var certHex = null; | ||
if (certStr.match(/^[0-9A-Fa-f]+$/)) { | ||
certHex == certStr; | ||
} | ||
if (certStr.indexOf("-----BEGIN ") != -1) { | ||
certHex = X509.pemToHex(certStr); | ||
} | ||
if (certHex == null) throw "certissuer param not cert"; | ||
var x = new X509(); | ||
x.hex = certHex; | ||
var dnHex = x.getIssuerHex(); | ||
v = new KJUR.asn1.ASN1Object(); | ||
v.hTLV = dnHex; | ||
} | ||
if (typeof params.certsubj != "undefined") { | ||
this.type = 'dn'; | ||
this.explicit = true; | ||
var certStr = params.certsubj; | ||
var certHex = null; | ||
if (certStr.match(/^[0-9A-Fa-f]+$/)) { | ||
certHex == certStr; | ||
} | ||
if (certStr.indexOf("-----BEGIN ") != -1) { | ||
certHex = X509.pemToHex(certStr); | ||
} | ||
if (certHex == null) throw "certsubj param not cert"; | ||
var x = new X509(); | ||
x.hex = certHex; | ||
var dnHex = x.getSubjectHex(); | ||
v = new KJUR.asn1.ASN1Object(); | ||
v.hTLV = dnHex; | ||
} | ||
|
||
if (this.type == null) | ||
throw "unsupported type in params=" + params; | ||
this.asn1Obj = new KJUR.asn1.DERTaggedObject({'explicit': false, | ||
this.asn1Obj = new KJUR.asn1.DERTaggedObject({'explicit': this.explicit, | ||
'tag': pTag[this.type], | ||
'obj': v}); | ||
}; | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.