├── README.md ├── assets ├── css │ └── style.css ├── img │ ├── appbar.usb.drive.svg │ └── icons.svg ├── js │ └── script.js └── key │ ├── privatekey.txt │ └── publickey.txt ├── index.html └── jsrsasign ├── ChangeLog.txt ├── LICENSE.txt ├── README.md ├── api ├── files.html ├── index.html └── symbols │ ├── ASN1HEX.html │ ├── Base64x.html │ ├── KEYUTIL.html │ ├── KJUR.asn1.ASN1Object.html │ ├── KJUR.asn1.ASN1Util.html │ ├── KJUR.asn1.DERAbstractString.html │ ├── KJUR.asn1.DERAbstractStructured.html │ ├── KJUR.asn1.DERAbstractTime.html │ ├── KJUR.asn1.DERBitString.html │ ├── KJUR.asn1.DERBoolean.html │ ├── KJUR.asn1.DERGeneralizedTime.html │ ├── KJUR.asn1.DERIA5String.html │ ├── KJUR.asn1.DERInteger.html │ ├── KJUR.asn1.DERNull.html │ ├── KJUR.asn1.DERNumericString.html │ ├── KJUR.asn1.DERObjectIdentifier.html │ ├── KJUR.asn1.DEROctetString.html │ ├── KJUR.asn1.DERPrintableString.html │ ├── KJUR.asn1.DERSequence.html │ ├── KJUR.asn1.DERSet.html │ ├── KJUR.asn1.DERTaggedObject.html │ ├── KJUR.asn1.DERTeletexString.html │ ├── KJUR.asn1.DERUTCTime.html │ ├── KJUR.asn1.DERUTF8String.html │ ├── KJUR.asn1.html │ ├── KJUR.asn1.x509.AlgorithmIdentifier.html │ ├── KJUR.asn1.x509.AttributeTypeAndValue.html │ ├── KJUR.asn1.x509.AuthorityKeyIdentifier.html │ ├── KJUR.asn1.x509.BasicConstraints.html │ ├── KJUR.asn1.x509.CRL.html │ ├── KJUR.asn1.x509.CRLDistributionPoints.html │ ├── KJUR.asn1.x509.CRLEntry.html │ ├── KJUR.asn1.x509.Certificate.html │ ├── KJUR.asn1.x509.DistributionPoint.html │ ├── KJUR.asn1.x509.DistributionPointName.html │ ├── KJUR.asn1.x509.ExtKeyUsage.html │ ├── KJUR.asn1.x509.Extension.html │ ├── KJUR.asn1.x509.GeneralName.html │ ├── KJUR.asn1.x509.GeneralNames.html │ ├── KJUR.asn1.x509.KeyUsage.html │ ├── KJUR.asn1.x509.OID.html │ ├── KJUR.asn1.x509.RDN.html │ ├── KJUR.asn1.x509.SubjectPublicKeyInfo.html │ ├── KJUR.asn1.x509.TBSCertList.html │ ├── KJUR.asn1.x509.TBSCertificate.html │ ├── KJUR.asn1.x509.Time.html │ ├── KJUR.asn1.x509.X500Name.html │ ├── KJUR.asn1.x509.X509Util.html │ ├── KJUR.asn1.x509.html │ ├── KJUR.crypto.DSA.html │ ├── KJUR.crypto.ECDSA.html │ ├── KJUR.crypto.ECParameterDB.html │ ├── KJUR.crypto.Mac.html │ ├── KJUR.crypto.MessageDigest.html │ ├── KJUR.crypto.OID.html │ ├── KJUR.crypto.Signature.html │ ├── KJUR.crypto.Util.html │ ├── KJUR.crypto.html │ ├── KJUR.html │ ├── PKCS5PKEY.html │ ├── RSAKey.html │ ├── X509.html │ ├── global__.html │ └── src │ ├── asn1-1.0.js.html │ ├── asn1hex-1.1.js.html │ ├── asn1x509-1.0.js.html │ ├── base64x-1.1.js.html │ ├── crypto-1.1.js.html │ ├── dsa-modified-1.0.js.html │ ├── ecdsa-modified-1.0.js.html │ ├── ecparam-1.0.js.html │ ├── keyutil-1.0.js.html │ ├── pkcs5pkey-1.0.js.html │ ├── rsapem-1.1.js.html │ ├── rsasign-1.2.js.html │ └── x509-1.1.js.html ├── asn1-1.0.js ├── asn1-1.0.min.js ├── asn1hex-1.1.js ├── asn1hex-1.1.min.js ├── asn1x509-1.0.js ├── asn1x509-1.0.min.js ├── base64x-1.1.js ├── base64x-1.1.min.js ├── crypto-1.0.js ├── crypto-1.0.min.js ├── crypto-1.1.js ├── crypto-1.1.min.js ├── dsa-modified-1.0.js ├── dsa-modified-1.0.min.js ├── ecdsa-modified-1.0.js ├── ecdsa-modified-1.0.min.js ├── ecparam-1.0.js ├── ecparam-1.0.min.js ├── ext ├── THIRDPARTY_LICENSE.bitcoin.txt ├── THIRDPARTY_LICENSE.cryptojs.txt ├── THIRDPARTY_LICENSE.pgp.txt ├── THIRDPARTY_LICENSE.tomwu.txt ├── THIRDPARTY_LICENSE.txt ├── THIRDPARTY_LICENSE.yui.txt ├── base64-min.js ├── base64.js ├── cryptojs-312-core-fix-min.js ├── cryptojs-312-core-fix.js ├── ec-min.js ├── ec-patch-min.js ├── ec-patch.js ├── ec.js ├── jsbn-min.js ├── jsbn.js ├── jsbn2-min.js ├── jsbn2.js ├── md5.js ├── prng4-min.js ├── prng4.js ├── ripemd160.js ├── rng-min.js ├── rng.js ├── rsa-min.js ├── rsa.js ├── rsa2-min.js ├── rsa2.js ├── sha1.js ├── sha256.js └── sha512.js ├── index.html ├── index_ut.html ├── jsrsasign-4.1.1-all-min.js ├── jsrsasign-4.1.2-all-min.js ├── jsrsasign-4.1.3-all-min.js ├── jsrsasign-4.1.4-all-min.js ├── jsrsasign-4.1.6-all-min.js ├── jsrsasign-4.2.0-all-min.js ├── jsrsasign-4.2.1-all-min.js ├── jsrsasign-4.2.2-all-min.js ├── jsrsasign-latest-all-min.js ├── keyutil-1.0.js ├── keyutil-1.0.min.js ├── npm ├── Makefile ├── README.md ├── lib │ ├── footer.js │ ├── header.js │ ├── jsrsasign.js │ └── lib.js └── package.json ├── pkcs5pkey-1.0.js ├── pkcs5pkey-1.0.min.js ├── rsapem-1.1.js ├── rsapem-1.1.min.js ├── rsasign-1.2.js ├── rsasign-1.2.min.js ├── sample-ecdsa.html ├── sample-rsasign.html ├── sample-rsasign.png ├── test ├── jquery-1.4.2.min.js ├── qunit-do-asn1-newobj.html ├── qunit-do-asn1.html ├── qunit-do-asn1hex.html ├── qunit-do-asn1x509-newcrt.html ├── qunit-do-asn1x509.html ├── qunit-do-base64x.html ├── qunit-do-crypto-ecdsa.html ├── qunit-do-crypto-mac.html ├── qunit-do-crypto-pss.html ├── qunit-do-crypto-sigini.html ├── qunit-do-crypto-siginidsa.html ├── qunit-do-crypto-sjcl.html ├── qunit-do-crypto.html ├── qunit-do-dsa.html ├── qunit-do-ecdsamod-s.html ├── qunit-do-ecdsamod.html ├── qunit-do-ecparam.html ├── qunit-do-keyutil-csr.html ├── qunit-do-keyutil-des.html ├── qunit-do-keyutil-dsa.html ├── qunit-do-keyutil-eprv.html ├── qunit-do-keyutil-gen.html ├── qunit-do-keyutil-getpem.html ├── qunit-do-keyutil-pub.html ├── qunit-do-keyutil.html ├── qunit-do-pkcs5-eprv.html ├── qunit-do-pkcs5-pub.html ├── qunit-do-pkcs5.html ├── qunit-do-rsapem.html ├── qunit-do-rsasign-pss.html ├── qunit-do-rsasign.html ├── qunit-do-x509-key.html ├── qunit-do-x509.html ├── qunit.css └── qunit.js ├── tool_ca.html ├── tool_certview.html ├── tool_forfact.html ├── tool_pkcs5view.html ├── x509-1.1.js └── x509-1.1.min.js /README.md: -------------------------------------------------------------------------------- 1 | Assinatura Digital JavaScript 2 | =========================== 3 | Baseado no projeto [JavaScript File Encryption App](http://tutorialzine.com/2013/11/javascript-file-encrypter/) 4 | 5 | Demonstração [Demo](http://phelipealves.github.io/assinaturadigitaljavascript/) 6 | 7 | * Motivação: portais que produzem informações sigilosas ou que exigem a assinatura digital de quem produz a informação em questão, podem se beneficiar do emprego de JavaScript para execução de tais operações e, desta forma, desobrigar a instalação de plug-in para a realização de tais operações. 8 | * Usar recurso como jsrasign (http://kjur.github.io/jsrsasign/) ou equivalente pode ser empregado para este trabalho. 9 | * Criar uma página por meio da qual se seleciona um documento e outras informações necessárias para que o documento seja assinado digitalmente. 10 | * No sentido inverso, a página deverá, ao receber um documento assinado, verificar a assinatura do mesmo. 11 | * É possível e provável a interação com leitor de token contendo o certificado digital empregado para assinar o documento e, neste caso, devem ser observadas as recomendações do ICP-Brasil, se for o caso. Isto se aplica a padrões, dispositivos possíveis e outros. 12 | 13 | ============================ 14 | Passos da aplicação 15 | 16 | * Passo 1 17 | * Assinatura Digital via JavaScript 18 | * Opções (Assinar um arquivo ou Verificar assinatura). 19 | * Passo 2 20 | * **(Assinar)** Escolha um arquivo para assinar. 21 | * **(Verificar)** Escolha um arquivo verificar a assinatura. 22 | * **(Assinar e Verificar)** Ler esse arquivo e converter os Bytes em String. 23 | * Passo 3 24 | * **(Assinar)** Insira a chave privada 25 | * **(Verificar)** Insira a chave pública 26 | * Poderá ser inserida a chave Pública no campo de texto. 27 | * **(Assinar e Verificar)** Poderá ser selecionada as chaves padrões do sistema, salvas em arquivos locais. Simulando uma leitura de um cartão, pen drive ou discos com assinatura de hardware. 28 | * **(Para esse item deve ser observado que a iteração do javascript com o hardware depende de outras aplicações rodando no computador do cliente para a leitura da chave privada. Uma solução possível seria a criação de uma aplicação nativa no cliente que se comunicasse com os dispositivos e disponibilizasse uma porta de acesso para o javascript ex:localhost:2406, sendo que cada vez que fosse realizado uma requisição nessa porta pelo javascript, essa aplicação iria realizar a leitura dos dispositivos e retornar a string contendo a chave).** 29 | 30 | * Passo 4 31 | * **(Assinar)** Selecione o algoritmo de assinatura ( SHA1, SHA256, SHA512, MD5, RIPEMD-160 ). 32 | * Assina o arquivo e cria o link para baixar o arquivo com a assinatura. 33 | * **(Verificar)** Selecione o arquivo com assinatura 34 | * Passo 5 35 | * **(Assinar)** Download do arquivo com a assinatura. 36 | * **(Verificar)** Status da verificação 37 | * _"Assinatura válida!"_. 38 | * _"Assinatura inválida!"_. 39 | 40 | -------------------------------------------------------------------------------- /assets/css/style.css: -------------------------------------------------------------------------------- 1 | /*------------------------- 2 | Simple reset 3 | --------------------------*/ 4 | 5 | 6 | *{ 7 | margin:0; 8 | padding:0; 9 | } 10 | 11 | 12 | /*------------------------- 13 | General Styles 14 | --------------------------*/ 15 | 16 | 17 | html{ 18 | overflow:hidden; 19 | } 20 | 21 | a, a:visited { 22 | outline:none; 23 | color:#389dc1; 24 | } 25 | 26 | a:hover{ 27 | text-decoration:none; 28 | } 29 | 30 | section, footer, header, aside{ 31 | display: block; 32 | } 33 | 34 | textarea{ 35 | background-color: #fff; 36 | border: none; 37 | padding: 8px 18px; 38 | line-height: 1; 39 | font: inherit; 40 | display: inline-block; 41 | outline: none; 42 | margin-bottom: 5px; 43 | border-radius: 2px; 44 | box-shadow: 3px 3px 0 rgba(0,0,0,0.05); 45 | font-size: 20px; 46 | color: #555; 47 | } 48 | 49 | 50 | /*------------------------- 51 | The main page elements 52 | --------------------------*/ 53 | 54 | 55 | body{ 56 | font:15px/1.3 'Raleway', sans-serif; 57 | color: #fff; 58 | width:100%; 59 | height:100%; 60 | position:absolute; 61 | overflow:hidden; 62 | } 63 | 64 | #stage{ 65 | width:100%; 66 | height:100%; 67 | position:absolute; 68 | top:0; 69 | left:0; 70 | 71 | transition:top 0.4s; 72 | } 73 | 74 | #stage > div{ /* The step divs */ 75 | height:100%; 76 | position:relative; 77 | } 78 | 79 | 80 | #stage h1{ 81 | font-weight:normal; 82 | font-size:48px; 83 | text-align:center; 84 | color:#fff; 85 | margin-bottom:60px; 86 | } 87 | 88 | #stage h2{ 89 | font-weight: normal; 90 | font-size: 14px; 91 | font-family: Arial, Helvetica, sans-serif; 92 | margin: -40px 0 45px; 93 | font-style: italic; 94 | } 95 | 96 | .content{ 97 | position:absolute; 98 | text-align:center; 99 | left:0; 100 | top:50%; 101 | width:100%; 102 | } 103 | 104 | .content input[type=file]{ 105 | display:none; 106 | } 107 | 108 | a.back{ 109 | width: 32px; 110 | height: 32px; 111 | background: url('../img/icons.svg') no-repeat -192px 0; 112 | position: absolute; 113 | cursor: pointer; 114 | top: 50px; 115 | left: 50%; 116 | z-index: 10; 117 | opacity: 0.8; 118 | margin-left: -16px; 119 | display:none; 120 | } 121 | 122 | a.back:hover{ 123 | opacity:1; 124 | } 125 | 126 | 127 | /*------------------------- 128 | Conditional classes 129 | --------------------------*/ 130 | 131 | 132 | [class*="if-"]{ 133 | display:none; 134 | } 135 | 136 | body.encrypt .if-encrypt{ 137 | display:block; 138 | } 139 | 140 | body.decrypt .if-decrypt{ 141 | display:block; 142 | } 143 | 144 | 145 | /*------------------------- 146 | Button styles 147 | --------------------------*/ 148 | 149 | 150 | .button{ 151 | width:300px; 152 | height:70px; 153 | text-align:center; 154 | text-decoration: none !important; 155 | color:#fff !important; 156 | text-transform: uppercase; 157 | font-weight: bold; 158 | border-radius:1px; 159 | display:block; 160 | line-height:70px; 161 | box-shadow:3px 3px 0 rgba(0,0,0,0.08); 162 | cursor: pointer; 163 | font-size:18px; 164 | margin:10px auto; 165 | opacity:0.9; 166 | } 167 | 168 | .button:hover{ 169 | opacity:1; 170 | } 171 | 172 | .button::before{ 173 | content:''; 174 | background: url(../img/icons.svg) no-repeat; 175 | display: inline-block; 176 | width: 32px; 177 | height: 32px; 178 | vertical-align: middle; 179 | padding-right: 13px; 180 | } 181 | 182 | .button.green{ 183 | background-color:#92cd84; 184 | } 185 | 186 | .button.magenta{ 187 | background-color:#e661b7; 188 | } 189 | 190 | .button.blue{ 191 | background-color:#798dd7; 192 | } 193 | 194 | .button.red{ 195 | background-color: #c15645; 196 | } 197 | 198 | /* Styles for specific buttons */ 199 | 200 | .button.browse{ 201 | width:180px; 202 | } 203 | 204 | .button.sign{ 205 | width:190px; 206 | } 207 | 208 | .button.check{ 209 | width:190px; 210 | } 211 | 212 | .button.continue{ 213 | width:190px; 214 | } 215 | 216 | .button.download{ 217 | width:216px; 218 | } 219 | 220 | .button.cardreader{ 221 | width:190px; 222 | } 223 | 224 | .button.cardreader::before{ 225 | background: url(../img/appbar.usb.drive.svg) no-repeat; 226 | background-size: 32px 32px; 227 | color: white; 228 | } 229 | 230 | .button.encrypt::before{ 231 | background-position: 0 0; 232 | } 233 | 234 | .button.decrypt::before{ 235 | background-position: -96px 0; 236 | } 237 | 238 | .button.browse::before{ 239 | background-position: -240px 0; 240 | } 241 | 242 | .button.sign::before{ 243 | background-position: 0 0; 244 | } 245 | 246 | .button.check::before{ 247 | background-position: -96px 0; 248 | } 249 | 250 | .button.continue::before{ 251 | background-position: 0 0; 252 | } 253 | 254 | .button.download:before{ 255 | background-position:-48px 0; 256 | } 257 | 258 | 259 | /*------------------------- 260 | The steps 261 | --------------------------*/ 262 | 263 | 264 | #step1{ 265 | background-color:#75c0d1; 266 | } 267 | 268 | body.encrypt #step2{ 269 | background-color: #9ad58c; 270 | } 271 | 272 | body.decrypt #step2{ 273 | background-color: #E7A8D1; 274 | } 275 | 276 | body.encrypt #step3{ 277 | background-color:#d5d788; 278 | } 279 | 280 | body.decrypt #step3{ 281 | background-color:#FFA64D; 282 | } 283 | 284 | #step3 input[type=password]{ 285 | background-color: #fff; 286 | border: none; 287 | padding: 8px 18px; 288 | line-height: 1; 289 | font: inherit; 290 | display: inline-block; 291 | outline: none; 292 | width: 400px; 293 | margin-bottom: 18px; 294 | border-radius: 2px; 295 | box-shadow: 3px 3px 0 rgba(0,0,0,0.05); 296 | font-size: 20px; 297 | color: #555; 298 | } 299 | 300 | body.encrypt #step4{ 301 | background-color:#AA8CD8; 302 | } 303 | 304 | body.decrypt #step4{ 305 | background-color:#AAAAAA; 306 | } 307 | 308 | #step4{ 309 | background-color:#aa8cd8; 310 | } 311 | 312 | #step4 select{ 313 | background-color: #fff; 314 | border: none; 315 | padding: 8px 18px; 316 | line-height: 1; 317 | font: inherit; 318 | display: inline-block; 319 | outline: none; 320 | margin-bottom: 5px; 321 | border-radius: 2px; 322 | box-shadow: 3px 3px 0 rgba(0,0,0,0.05); 323 | font-size: 20px; 324 | color: #555; 325 | } 326 | 327 | #step5{ 328 | background-color:#26C9FF; 329 | } 330 | 331 | #step1 .content{ margin-top: -140px;} 332 | #step2 .content{ margin-top:-110px;} 333 | #step3 .content{ margin-top: -157px;} 334 | #step4 .content{ margin-top: -100px;} 335 | 336 | 337 | /*---------------------------- 338 | The Demo Footer 339 | -----------------------------*/ 340 | 341 | 342 | footer{ 343 | 344 | width: 770px; 345 | font: normal 16px Arial, Helvetica, sans-serif; 346 | padding: 15px 35px; 347 | position: fixed; 348 | bottom: 0; 349 | left: 50%; 350 | margin-left: -420px; 351 | 352 | background-color:#1f1f1f; 353 | background-image:linear-gradient(to bottom, #1f1f1f, #101010); 354 | 355 | border-radius:2px 2px 0 0; 356 | box-shadow: 0 -1px 4px rgba(0,0,0,0.4); 357 | z-index:1; 358 | } 359 | 360 | footer a.tz{ 361 | font-weight:normal; 362 | font-size:16px !important; 363 | text-decoration:none !important; 364 | display:block; 365 | margin-right: 300px; 366 | text-overflow:ellipsis; 367 | white-space: nowrap; 368 | color:#bfbfbf !important; 369 | z-index:1; 370 | } 371 | 372 | footer a.tz:before{ 373 | content: ''; 374 | background: url('http://cdn.tutorialzine.com/misc/enhance/v2_footer_bg.png') no-repeat 0 -53px; 375 | width: 138px; 376 | height: 20px; 377 | display: inline-block; 378 | position: relative; 379 | bottom: -3px; 380 | } 381 | 382 | footer .close{ 383 | position: absolute; 384 | cursor: pointer; 385 | width: 8px; 386 | height: 8px; 387 | background: url('http://cdn.tutorialzine.com/misc/enhance/v2_footer_bg.png') no-repeat 0 0px; 388 | top:10px; 389 | right:10px; 390 | z-index: 3; 391 | } 392 | 393 | footer #tzine-actions{ 394 | position: absolute; 395 | top: 8px; 396 | width: 500px; 397 | right: 50%; 398 | margin-right: -650px; 399 | text-align: right; 400 | z-index: 2; 401 | } 402 | 403 | footer #tzine-actions iframe{ 404 | display: inline-block; 405 | height: 21px; 406 | width: 95px; 407 | position: relative; 408 | float: left; 409 | margin-top: 11px; 410 | } 411 | -------------------------------------------------------------------------------- /assets/img/appbar.usb.drive.svg: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /assets/img/icons.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /assets/key/privatekey.txt: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICWwIBAAKBgQDRhGF7X4A0ZVlEg594WmODVVUIiiPQs04aLmvfg8SborHss5gQXu0aIdUT6nb5rTh5hD2yfpF2WIW6M8z0WxRhwicgXwi80H1aLPf6lEPPLvN29EhQNjBpkFkAJUbS8uuhJEeKw0cE49g80eBBF4BCqSL6PFQbP9/rByxdxEoAIQIDAQABAoGAA9/q3Zk6ib2GFRpKDLO/O2KMnAfR+b4XJ6zMGeoZ7Lbpi3MW0Nawk9ckVaX0ZVGqxbSIX5Cvp/yjHHpww+QbUFrw/gCjLiiYjM9E8C3uAF5AKJ0r4GBPl4u8K4bpbXeSxSB60/wPQFiQAJVcA5xhZVzqNuF3EjuKdHsw+dk+dPECQQDubX/lVGFgD/xYuchz56Yc7VHX+58BUkNSewSzwJRbcueqknXRWwj97SXqpnYfKqZq78dnEF10SWsr/NMKi+7XAkEA4PVqDv/OZAbWr4syXZNv/Mpl4r5suzYMMUD9U8B2JIRnrhmGZPzLx23N9J4hEJ+Xh8tSKVc80jOkrvGlSv+BxwJAaTOtjA3YTV+gU7Hdza53sCnSw/8FYLrgc6NOJtYhX9xqdevbyn1lkU0zPr8mPYg/F84m6MXixm2iuSz8HZoyzwJARi2paYZ5/5B2lwroqnKdZBJMGKFpUDn7Mb5hiSgocxnvMkv6NjT66Xsi3iYakJII9q8CMa1qZvT/cigmdbAh7wJAQNXyoizuGEltiSaBXx4H29EdXNYWDJ9SS5f070BRbAIldqRh3rcNvpY6BKJqFapda1DjdcncZECMizT/GMrc1w== 3 | -----END RSA PRIVATE KEY----- -------------------------------------------------------------------------------- /assets/key/publickey.txt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIBvTCCASYCCQD55fNzc0WF7TANBgkqhkiG9w0BAQUFADAjMQswCQYDVQQGEwJK 3 | UDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwHhcNMTAwNTI4MDIwODUxWhcNMjAwNTI1 4 | MDIwODUxWjAjMQswCQYDVQQGEwJKUDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwgZ8w 5 | DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANGEYXtfgDRlWUSDn3haY4NVVQiKI9Cz 6 | Thoua9+DxJuiseyzmBBe7Roh1RPqdvmtOHmEPbJ+kXZYhbozzPRbFGHCJyBfCLzQ 7 | fVos9/qUQ88u83b0SFA2MGmQWQAlRtLy66EkR4rDRwTj2DzR4EEXgEKpIvo8VBs/ 8 | 3+sHLF3ESgAhAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAEZ6mXFFq3AzfaqWHmCy1 9 | ARjlauYAa8ZmUFnLm0emg9dkVBJ63aEqARhtok6bDQDzSJxiLpCEF6G4b/Nv/M/M 10 | LyhP+OoOTmETMegAVQMq71choVJyOFE5BtQa6M/lCHEOya5QUfoRF2HF9EjRF44K 11 | 3OK+u3ivTSj3zwjtpudY5Xo= 12 | -----END CERTIFICATE----- -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Assinatura Digital via JavaScript 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 | 43 |
44 |
45 |

Assinatura Digital via JavaScript

46 | Assinar um arquivo 47 | Verificar assinatura 48 |
49 |
50 | 51 |
52 | 53 |
54 | 55 | 56 |

Escolha um arquivo para assinar

57 |

Uma cópia assinada do arquivo será gerado. Nenhum dado é enviado para o nosso servidor.

58 | Selecionar 59 | 60 | 61 |
62 | 63 |
64 |

Escolha o arquivo para verificar

65 |

Apenas arquivos assinados serão aceitos.

66 | Selecionar 67 | 68 | 69 |
70 | 71 |
72 | 73 |
74 | 75 |
76 | 77 | 78 |

Insira a chave privada

79 |

Esta chave vai ser utilizada para a assinatura do documento.

80 | 81 | Ler cartão 82 |
83 | 84 |
85 | 86 | 87 |

Insira a chave pública

88 |

Digite a chave pública do assinante para verificar este arquivo. Não será possível verificar sem ela.

89 | 90 | 91 | 92 | Continuar 93 |
94 | 95 |
96 | 97 |
98 | 99 |
100 | 101 |

Selecione o algoritmo de assinatura

102 | 103 | 110 | Assinar! 111 |
112 | 113 |
114 |

Selecione o arquivo com assinatura

115 | Selecionar 116 | 117 | 118 |
119 | 120 |
121 | 122 |
123 |
124 |

Seu arquivo foi assinado!

125 |

Baixe a assinatura do arquivo!

126 | Download 127 |
128 | 129 |
130 |
131 |
132 | 133 |
134 | 135 |
136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /jsrsasign/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | The 'jsrsasign'(RSA-Sign JavaScript Library) License 3 | 4 | Copyright (c) 2010-2013 Kenji Urushima 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /jsrsasign/README.md: -------------------------------------------------------------------------------- 1 | jsrsasign 2 | ========= 3 | 4 | The 'jsrsasign' (RSA-Sign JavaScript Library) is an opensource free pure JavaScript cryptographic library supports RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate and CRL 5 | 6 | Public page is http://kjur.github.com/jsrsasign . 7 | 8 | Your bugfix and pull request contribution are always welcomed :) 9 | -------------------------------------------------------------------------------- /jsrsasign/asn1hex-1.1.min.js: -------------------------------------------------------------------------------- 1 | /*! asn1hex-1.1.4.js (c) 2012-2013 Kenji Urushima | kjur.github.com/jsrsasign/license 2 | */ 3 | var ASN1HEX=new function(){this.getByteLengthOfL_AtObj=function(b,c){if(b.substring(c+2,c+3)!="8"){return 1}var a=parseInt(b.substring(c+3,c+4));if(a==0){return -1}if(0=(b*2))){break}if(d>=200){break}c.push(e);g=e;d++}return c};this.getNthChildIndex_AtObj=function(d,b,e){var c=this.getPosArrayOfChildren_AtObj(d,b);return c[e]};this.getDecendantIndexByNthList=function(e,d,c){if(c.length==0){return d}var f=c.shift();var b=this.getPosArrayOfChildren_AtObj(e,d);return this.getDecendantIndexByNthList(e,b[f],c)};this.getDecendantHexTLVByNthList=function(d,c,b){var a=this.getDecendantIndexByNthList(d,c,b);return this.getHexOfTLV_AtObj(d,a)};this.getDecendantHexVByNthList=function(d,c,b){var a=this.getDecendantIndexByNthList(d,c,b);return this.getHexOfV_AtObj(d,a)}};ASN1HEX.getVbyList=function(d,c,b,e){var a=this.getDecendantIndexByNthList(d,c,b);if(a===undefined){throw"can't find nthList object"}if(e!==undefined){if(d.substr(a,2)!=e){throw"checking tag doesn't match: "+d.substr(a,2)+"!="+e}}return this.getHexOfV_AtObj(d,a)}; -------------------------------------------------------------------------------- /jsrsasign/base64x-1.1.min.js: -------------------------------------------------------------------------------- 1 | /*! base64x-1.1.2 (c) 2013 Kenji Urushima | kjur.github.com/jsjws/license 2 | */ 3 | function Base64x(){}function stoBA(d){var b=new Array();for(var c=0;cd){throw"key is too short for SigAlg: keylen="+j+","+a}var b="0001";var k="00"+c;var g="";var l=d-b.length-k.length;for(var f=0;f0||K.compareTo(u)>0||BigInteger.ZERO.compareTo(J)>0||J.compareTo(u)>0){throw"invalid DSA signature"}var I=J.modInverse(u);var A=D.multiply(I).mod(u);var v=K.multiply(I).mod(u);var F=G.modPow(A,z).multiply(H.modPow(v,z)).mod(z).mod(u);return F.compareTo(K)==0};this.parseASN1Signature=function(u){try{var y=new BigInteger(ASN1HEX.getVbyList(u,0,[0],"02"),16);var v=new BigInteger(ASN1HEX.getVbyList(u,0,[1],"02"),16);return[y,v]}catch(w){throw"malformed DSA signature"}};function d(E,w,B,v,u,C){var z=KJUR.crypto.Util.hashString(w,E.toLowerCase());var z=z.substr(0,u.bitLength()/4);var A=new BigInteger(z,16);var y=n(BigInteger.ONE.add(BigInteger.ONE),u.subtract(BigInteger.ONE));var F=(B.modPow(y,v)).mod(u);var D=(y.modInverse(u).multiply(A.add(C.multiply(F)))).mod(u);var G=new Array();G[0]=F;G[1]=D;return G}function r(v){var u=openpgp.config.config.prefer_hash_algorithm;switch(Math.round(v.bitLength()/8)){case 20:if(u!=2&&u>11&&u!=10&&u<8){return 2}return u;case 28:if(u>11&&u<8){return 11}return u;case 32:if(u>10&&u<8){return 8}return u;default:util.print_debug("DSA select hash algorithm: returning null for an unknown length of q");return null}}this.select_hash_algorithm=r;function m(I,K,J,B,z,u,F,G){var C=KJUR.crypto.Util.hashString(B,I.toLowerCase());var C=C.substr(0,u.bitLength()/4);var D=new BigInteger(C,16);if(BigInteger.ZERO.compareTo(K)>0||K.compareTo(u)>0||BigInteger.ZERO.compareTo(J)>0||J.compareTo(u)>0){util.print_error("invalid DSA Signature");return null}var H=J.modInverse(u);var A=D.multiply(H).mod(u);var v=K.multiply(H).mod(u);var E=F.modPow(A,z).multiply(G.modPow(v,z)).mod(z).mod(u);return E.compareTo(K)==0}function a(z){var A=new BigInteger(z,primeCenterie);var y=j(q,512);var u=t(p,q,z);var v;do{v=new BigInteger(q.bitCount(),rand)}while(x.compareTo(BigInteger.ZERO)!=1&&x.compareTo(q)!=-1);var w=g.modPow(x,p);return{x:v,q:A,p:y,g:u,y:w}}function j(y,z,w){if(z%64!=0){return false}var u;var v;do{u=w(bitcount,true);v=u.subtract(BigInteger.ONE);u=u.subtract(v.remainder(y))}while(!u.isProbablePrime(primeCenterie)||u.bitLength()!=l);return u}function t(B,z,A,w){var u=B.subtract(BigInteger.ONE);var y=u.divide(z);var v;do{v=w(A)}while(v.compareTo(u)!=-1&&v.compareTo(BigInteger.ONE)!=1);return v.modPow(y,B)}function o(w,y,u){var v;do{v=u(y,false)}while(v.compareTo(w)!=-1&&v.compareTo(BigInteger.ZERO)!=1);return v}function i(v,w){k=o(v);var u=g.modPow(k,w).mod(v);return u}function h(B,w,y,v,z,u){var A=B(v);s=(w.modInverse(z).multiply(A.add(u.multiply(y)))).mod(z);return s}this.sign=d;this.verify=m;function n(w,u){if(u.compareTo(w)<=0){return}var v=u.subtract(w);var y=e(v.bitLength());while(y>v){y=e(v.bitLength())}return w.add(y)}function e(w){if(w<0){return null}var u=Math.floor((w+7)/8);var v=c(u);if(w%8>0){v=String.fromCharCode((Math.pow(2,w%8)-1)&v.charCodeAt(0))+v.substring(1)}return new BigInteger(f(v),16)}function c(w){var u="";for(var v=0;v=0;--p){q=q.twice2D();q.z=BigInteger.ONE;if(o.testBit(p)){if(n.testBit(p)){q=q.add2D(t)}else{q=q.add2D(s)}}else{if(n.testBit(p)){q=q.add2D(r)}}}return q}this.getBigRandom=function(i){return new BigInteger(i.bitLength(),a).mod(i.subtract(BigInteger.ONE)).add(BigInteger.ONE)};this.setNamedCurve=function(i){this.ecparams=KJUR.crypto.ECParameterDB.getByName(i);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=i};this.setPrivateKeyHex=function(i){this.isPrivate=true;this.prvKeyHex=i};this.setPublicKeyHex=function(i){this.isPublic=true;this.pubKeyHex=i};this.generateKeyPairHex=function(){var k=this.ecparams.n;var n=this.getBigRandom(k);var l=this.ecparams.G.multiply(n);var q=l.getX().toBigInteger();var o=l.getY().toBigInteger();var i=this.ecparams.keylen/4;var m=("0000000000"+n.toString(16)).slice(-i);var r=("0000000000"+q.toString(16)).slice(-i);var p=("0000000000"+o.toString(16)).slice(-i);var j="04"+r+p;this.setPrivateKeyHex(m);this.setPublicKeyHex(j);return{ecprvhex:m,ecpubhex:j}};this.signWithMessageHash=function(i){return this.signHex(i,this.prvKeyHex)};this.signHex=function(o,j){var t=new BigInteger(j,16);var l=this.ecparams.n;var q=new BigInteger(o,16);do{var m=this.getBigRandom(l);var u=this.ecparams.G;var p=u.multiply(m);var i=p.getX().toBigInteger().mod(l)}while(i.compareTo(BigInteger.ZERO)<=0);var v=m.modInverse(l).multiply(q.add(t.multiply(i))).mod(l);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(i,v)};this.sign=function(m,u){var q=u;var j=this.ecparams.n;var p=BigInteger.fromByteArrayUnsigned(m);do{var l=this.getBigRandom(j);var t=this.ecparams.G;var o=t.multiply(l);var i=o.getX().toBigInteger().mod(j)}while(i.compareTo(BigInteger.ZERO)<=0);var v=l.modInverse(j).multiply(p.add(q.multiply(i))).mod(j);return this.serializeSig(i,v)};this.verifyWithMessageHash=function(j,i){return this.verifyHex(j,i,this.pubKeyHex)};this.verifyHex=function(m,i,p){var l,j;var o=KJUR.crypto.ECDSA.parseSigHex(i);l=o.r;j=o.s;var k;k=ECPointFp.decodeFromHex(this.ecparams.curve,p);var n=new BigInteger(m,16);return this.verifyRaw(n,l,j,k)};this.verify=function(o,p,j){var l,i;if(Bitcoin.Util.isArray(p)){var n=this.parseSig(p);l=n.r;i=n.s}else{if("object"===typeof p&&p.r&&p.s){l=p.r;i=p.s}else{throw"Invalid value for signature"}}var k;if(j instanceof ECPointFp){k=j}else{if(Bitcoin.Util.isArray(j)){k=ECPointFp.decodeFrom(this.ecparams.curve,j)}else{throw"Invalid format for pubkey value, must be byte array or ECPointFp"}}var m=BigInteger.fromByteArrayUnsigned(o);return this.verifyRaw(m,l,i,k)};this.verifyRaw=function(o,i,w,m){var l=this.ecparams.n;var u=this.ecparams.G;if(i.compareTo(BigInteger.ONE)<0||i.compareTo(l)>=0){return false}if(w.compareTo(BigInteger.ONE)<0||w.compareTo(l)>=0){return false}var p=w.modInverse(l);var k=o.multiply(p).mod(l);var j=i.multiply(p).mod(l);var q=u.multiply(k).add(m.multiply(j));var t=q.getX().toBigInteger().mod(l);return t.equals(i)};this.serializeSig=function(k,j){var l=k.toByteArraySigned();var i=j.toByteArraySigned();var m=[];m.push(2);m.push(l.length);m=m.concat(l);m.push(2);m.push(i.length);m=m.concat(i);m.unshift(m.length);m.unshift(48);return m};this.parseSig=function(n){var m;if(n[0]!=48){throw new Error("Signature not a valid DERSequence")}m=2;if(n[m]!=2){throw new Error("First element in signature must be a DERInteger")}var l=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];if(n[m]!=2){throw new Error("Second element in signature must be a DERInteger")}var i=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];var k=BigInteger.fromByteArrayUnsigned(l);var j=BigInteger.fromByteArrayUnsigned(i);return{r:k,s:j}};this.parseSigCompact=function(m){if(m.length!==65){throw"Signature has the wrong length"}var j=m[0]-27;if(j<0||j>7){throw"Invalid signature type"}var o=this.ecparams.n;var l=BigInteger.fromByteArrayUnsigned(m.slice(1,33)).mod(o);var k=BigInteger.fromByteArrayUnsigned(m.slice(33,65)).mod(o);return{r:l,s:k,i:j}};if(h!==undefined){if(h.curve!==undefined){this.curveName=h.curve}}if(this.curveName===undefined){this.curveName=e}this.setNamedCurve(this.curveName);if(h!==undefined){if(h.prv!==undefined){this.setPrivateKeyHex(h.prv)}if(h.pub!==undefined){this.setPublicKeyHex(h.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(c){if(c.substr(0,2)!="30"){throw"signature is not a ASN.1 sequence"}var b=ASN1HEX.getPosArrayOfChildren_AtObj(c,0);if(b.length!=2){throw"number of signature ASN.1 sequence elements seem wrong"}var g=b[0];var f=b[1];if(c.substr(g,2)!="02"){throw"1st item of sequene of signature is not ASN.1 integer"}if(c.substr(f,2)!="02"){throw"2nd item of sequene of signature is not ASN.1 integer"}var e=ASN1HEX.getHexOfV_AtObj(c,g);var d=ASN1HEX.getHexOfV_AtObj(c,f);return{r:e,s:d}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(c){var d=KJUR.crypto.ECDSA.parseSigHexInHexRS(c);var b=d.r;var a=d.s;if(b.substr(0,2)=="00"&&(((b.length/2)*8)%(16*8))==8){b=b.substr(2)}if(a.substr(0,2)=="00"&&(((a.length/2)*8)%(16*8))==8){a=a.substr(2)}if((((b.length/2)*8)%(16*8))!=0){throw"unknown ECDSA sig r length error"}if((((a.length/2)*8)%(16*8))!=0){throw"unknown ECDSA sig s length error"}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if((((a.length/2)*8)%(16*8))!=0){throw"unknown ECDSA concatinated r-s sig length error"}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(e,c){var b=new KJUR.asn1.DERInteger({bigint:e});var a=new KJUR.asn1.DERInteger({bigint:c});var d=new KJUR.asn1.DERSequence({array:[b,a]});return d.getEncodedHex()}; -------------------------------------------------------------------------------- /jsrsasign/ecparam-1.0.min.js: -------------------------------------------------------------------------------- 1 | /*! ecparam-1.0.0.js (c) 2013 Kenji Urushima | kjur.github.com/jsrsasign/license 2 | */ 3 | if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.crypto=="undefined"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.ECParameterDB=new function(){var b={};var c={};function a(d){return new BigInteger(d,16)}this.getByName=function(e){var d=e;if(typeof c[d]!="undefined"){d=c[e]}if(typeof b[d]!="undefined"){return b[d]}throw"unregistered EC curve name: "+d};this.regist=function(A,l,o,g,m,e,j,f,k,u,d,x){b[A]={};var s=a(o);var z=a(g);var y=a(m);var t=a(e);var w=a(j);var r=new ECCurveFp(s,z,y);var q=r.decodePointHex("04"+f+k);b[A]["name"]=A;b[A]["keylen"]=l;b[A]["curve"]=r;b[A]["G"]=q;b[A]["n"]=t;b[A]["h"]=w;b[A]["oid"]=d;b[A]["info"]=x;for(var v=0;v>6)+b64map.charAt(e&63)}if(b+1==d.length){e=parseInt(d.substring(b,b+1),16);a+=b64map.charAt(e<<2)}else{if(b+2==d.length){e=parseInt(d.substring(b,b+2),16);a+=b64map.charAt(e>>2)+b64map.charAt((e&3)<<4)}}if(b64pad){while((a.length&3)>0){a+=b64pad}}return a}function b64tohex(f){var d="";var e;var b=0;var c;var a;for(e=0;e>2);c=a&3;b=1}else{if(b==1){d+=int2char((c<<2)|(a>>4));c=a&15;b=2}else{if(b==2){d+=int2char(c);d+=int2char(a>>2);c=a&3;b=3}else{d+=int2char((c<<2)|(a>>4));d+=int2char(a&15);b=0}}}}if(b==1){d+=int2char(c<<2)}return d}function b64toBA(e){var d=b64tohex(e);var c;var b=new Array();for(c=0;2*c> 6) + b64map.charAt(c & 63); 13 | } 14 | if(i+1 == h.length) { 15 | c = parseInt(h.substring(i,i+1),16); 16 | ret += b64map.charAt(c << 2); 17 | } 18 | else if(i+2 == h.length) { 19 | c = parseInt(h.substring(i,i+2),16); 20 | ret += b64map.charAt(c >> 2) + b64map.charAt((c & 3) << 4); 21 | } 22 | if (b64pad) while((ret.length & 3) > 0) ret += b64pad; 23 | return ret; 24 | } 25 | 26 | // convert a base64 string to hex 27 | function b64tohex(s) { 28 | var ret = "" 29 | var i; 30 | var k = 0; // b64 state, 0-3 31 | var slop; 32 | var v; 33 | for(i = 0; i < s.length; ++i) { 34 | if(s.charAt(i) == b64pad) break; 35 | v = b64map.indexOf(s.charAt(i)); 36 | if(v < 0) continue; 37 | if(k == 0) { 38 | ret += int2char(v >> 2); 39 | slop = v & 3; 40 | k = 1; 41 | } 42 | else if(k == 1) { 43 | ret += int2char((slop << 2) | (v >> 4)); 44 | slop = v & 0xf; 45 | k = 2; 46 | } 47 | else if(k == 2) { 48 | ret += int2char(slop); 49 | ret += int2char(v >> 2); 50 | slop = v & 3; 51 | k = 3; 52 | } 53 | else { 54 | ret += int2char((slop << 2) | (v >> 4)); 55 | ret += int2char(v & 0xf); 56 | k = 0; 57 | } 58 | } 59 | if(k == 1) 60 | ret += int2char(slop << 2); 61 | return ret; 62 | } 63 | 64 | // convert a base64 string to a byte/number array 65 | function b64toBA(s) { 66 | //piggyback on b64tohex for now, optimize later 67 | var h = b64tohex(s); 68 | var i; 69 | var a = new Array(); 70 | for(i = 0; 2*i < h.length; ++i) { 71 | a[i] = parseInt(h.substring(2*i,2*i+2),16); 72 | } 73 | return a; 74 | } 75 | -------------------------------------------------------------------------------- /jsrsasign/ext/cryptojs-312-core-fix-min.js: -------------------------------------------------------------------------------- 1 | /*! CryptoJS v3.1.2 core-fix.js 2 | * code.google.com/p/crypto-js 3 | * (c) 2009-2013 by Jeff Mott. All rights reserved. 4 | * code.google.com/p/crypto-js/wiki/License 5 | * THIS IS FIX of 'core.js' to fix Hmac issue. 6 | * https://code.google.com/p/crypto-js/issues/detail?id=84 7 | * https://crypto-js.googlecode.com/svn-history/r667/branches/3.x/src/core.js 8 | */ 9 | var CryptoJS=CryptoJS||(function(e,g){var a={};var b=a.lib={};var j=b.Base=(function(){function n(){}return{extend:function(p){n.prototype=this;var o=new n();if(p){o.mixIn(p)}if(!o.hasOwnProperty("init")){o.init=function(){o.$super.init.apply(this,arguments)}}o.init.prototype=o;o.$super=this;return o},create:function(){var o=this.extend();o.init.apply(o,arguments);return o},init:function(){},mixIn:function(p){for(var o in p){if(p.hasOwnProperty(o)){this[o]=p[o]}}if(p.hasOwnProperty("toString")){this.toString=p.toString}},clone:function(){return this.init.prototype.extend(this)}}}());var l=b.WordArray=j.extend({init:function(o,n){o=this.words=o||[];if(n!=g){this.sigBytes=n}else{this.sigBytes=o.length*4}},toString:function(n){return(n||h).stringify(this)},concat:function(t){var q=this.words;var p=t.words;var n=this.sigBytes;var s=t.sigBytes;this.clamp();if(n%4){for(var r=0;r>>2]>>>(24-(r%4)*8))&255;q[(n+r)>>>2]|=o<<(24-((n+r)%4)*8)}}else{for(var r=0;r>>2]=p[r>>>2]}}this.sigBytes+=s;return this},clamp:function(){var o=this.words;var n=this.sigBytes;o[n>>>2]&=4294967295<<(32-(n%4)*8);o.length=e.ceil(n/4)},clone:function(){var n=j.clone.call(this);n.words=this.words.slice(0);return n},random:function(p){var o=[];for(var n=0;n>>2]>>>(24-(n%4)*8))&255;q.push((s>>>4).toString(16));q.push((s&15).toString(16))}return q.join("")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>3]|=parseInt(p.substr(o,2),16)<<(24-(o%8)*4)}return new l.init(q,n/2)}};var d=m.Latin1={stringify:function(q){var r=q.words;var p=q.sigBytes;var n=[];for(var o=0;o>>2]>>>(24-(o%4)*8))&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>2]|=(p.charCodeAt(o)&255)<<(24-(o%4)*8)}return new l.init(q,n)}};var c=m.Utf8={stringify:function(n){try{return decodeURIComponent(escape(d.stringify(n)))}catch(o){throw new Error("Malformed UTF-8 data")}},parse:function(n){return d.parse(unescape(encodeURIComponent(n)))}};var i=b.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new l.init();this._nDataBytes=0},_append:function(n){if(typeof n=="string"){n=c.parse(n)}this._data.concat(n);this._nDataBytes+=n.sigBytes},_process:function(w){var q=this._data;var x=q.words;var n=q.sigBytes;var t=this.blockSize;var v=t*4;var u=n/v;if(w){u=e.ceil(u)}else{u=e.max((u|0)-this._minBufferSize,0)}var s=u*t;var r=e.min(s*4,n);if(s){for(var p=0;p0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add(a?this:l)}}return d}function pointFpMultiplyTwo(c,a,b){var d;if(c.bitLength()>b.bitLength()){d=c.bitLength()-1}else{d=b.bitLength()-1}var f=this.curve.getInfinity();var e=this.add(a);while(d>=0){f=f.twice();if(c.testBit(d)){if(b.testBit(d)){f=f.add(e)}else{f=f.add(this)}}else{if(b.testBit(d)){f=f.add(a)}}--d}return f}ECPointFp.prototype.getX=pointFpGetX;ECPointFp.prototype.getY=pointFpGetY;ECPointFp.prototype.equals=pointFpEquals;ECPointFp.prototype.isInfinity=pointFpIsInfinity;ECPointFp.prototype.negate=pointFpNegate;ECPointFp.prototype.add=pointFpAdd;ECPointFp.prototype.twice=pointFpTwice;ECPointFp.prototype.multiply=pointFpMultiply;ECPointFp.prototype.multiplyTwo=pointFpMultiplyTwo;function ECCurveFp(e,d,c){this.q=e;this.a=this.fromBigInteger(d);this.b=this.fromBigInteger(c);this.infinity=new ECPointFp(this,null,null)}function curveFpGetQ(){return this.q}function curveFpGetA(){return this.a}function curveFpGetB(){return this.b}function curveFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.a.equals(a.a)&&this.b.equals(a.b))}function curveFpGetInfinity(){return this.infinity}function curveFpFromBigInteger(a){return new ECFieldElementFp(this.q,a)}function curveFpDecodePointHex(d){switch(parseInt(d.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var a=(d.length-2)/2;var c=d.substr(2,a);var b=d.substr(a+2,a);return new ECPointFp(this,this.fromBigInteger(new BigInteger(c,16)),this.fromBigInteger(new BigInteger(b,16)));default:return null}}ECCurveFp.prototype.getQ=curveFpGetQ;ECCurveFp.prototype.getA=curveFpGetA;ECCurveFp.prototype.getB=curveFpGetB;ECCurveFp.prototype.equals=curveFpEquals;ECCurveFp.prototype.getInfinity=curveFpGetInfinity;ECCurveFp.prototype.fromBigInteger=curveFpFromBigInteger;ECCurveFp.prototype.decodePointHex=curveFpDecodePointHex; -------------------------------------------------------------------------------- /jsrsasign/ext/ec-patch-min.js: -------------------------------------------------------------------------------- 1 | /*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib 2 | */ 3 | ECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};ECPointFp.prototype.getEncoded=function(c){var d=function(h,f){var g=h.toByteArrayUnsigned();if(fg.length){g.unshift(0)}}return g};var a=this.getX().toBigInteger();var e=this.getY().toBigInteger();var b=d(a,32);if(c){if(e.isEven()){b.unshift(2)}else{b.unshift(3)}}else{b.unshift(4);b=b.concat(d(e,32))}return b};ECPointFp.decodeFrom=function(g,c){var f=c[0];var e=c.length-1;var d=c.slice(1,1+e/2);var b=c.slice(1+e/2,1+e);d.unshift(0);b.unshift(0);var a=new BigInteger(d);var h=new BigInteger(b);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.decodeFromHex=function(g,c){var f=c.substr(0,2);var e=c.length-2;var d=c.substr(2,e/2);var b=c.substr(2+e/2,e/2);var a=new BigInteger(d,16);var h=new BigInteger(b,16);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.prototype.add2D=function(c){if(this.isInfinity()){return c}if(c.isInfinity()){return this}if(this.x.equals(c.x)){if(this.y.equals(c.y)){return this.twice()}return this.curve.getInfinity()}var g=c.x.subtract(this.x);var e=c.y.subtract(this.y);var a=e.divide(g);var d=a.square().subtract(this.x).subtract(c.x);var f=a.multiply(this.x.subtract(d)).subtract(this.y);return new ECPointFp(this.curve,d,f)};ECPointFp.prototype.twice2D=function(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var b=this.curve.fromBigInteger(BigInteger.valueOf(2));var e=this.curve.fromBigInteger(BigInteger.valueOf(3));var a=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(b));var c=a.square().subtract(this.x.multiply(b));var d=a.multiply(this.x.subtract(c)).subtract(this.y);return new ECPointFp(this.curve,c,d)};ECPointFp.prototype.multiply2D=function(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger("3"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add2D(a?this:l)}}return d};ECPointFp.prototype.isOnCurve=function(){var d=this.getX().toBigInteger();var i=this.getY().toBigInteger();var f=this.curve.getA().toBigInteger();var c=this.curve.getB().toBigInteger();var h=this.curve.getQ();var e=i.multiply(i).mod(h);var g=d.multiply(d).multiply(d).add(f.multiply(d)).add(c).mod(h);return e.equals(g)};ECPointFp.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"};ECPointFp.prototype.validate=function(){var c=this.curve.getQ();if(this.isInfinity()){throw new Error("Point is at infinity.")}var a=this.getX().toBigInteger();var b=this.getY().toBigInteger();if(a.compareTo(BigInteger.ONE)<0||a.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error("x coordinate out of bounds")}if(b.compareTo(BigInteger.ONE)<0||b.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error("y coordinate out of bounds")}if(!this.isOnCurve()){throw new Error("Point is not on the curve.")}if(this.multiply(c).isInfinity()){throw new Error("Point is not a scalar multiple of G.")}return true}; -------------------------------------------------------------------------------- /jsrsasign/ext/ec-patch.js: -------------------------------------------------------------------------------- 1 | /*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib 2 | */ 3 | /* 4 | * splitted from bitcoin-lib/ecdsa.js 5 | * 6 | * version 1.0.0 is the original of bitcoin-lib/ecdsa.js 7 | */ 8 | ECFieldElementFp.prototype.getByteLength = function () { 9 | return Math.floor((this.toBigInteger().bitLength() + 7) / 8); 10 | }; 11 | 12 | ECPointFp.prototype.getEncoded = function (compressed) { 13 | var integerToBytes = function(i, len) { 14 | var bytes = i.toByteArrayUnsigned(); 15 | 16 | if (len < bytes.length) { 17 | bytes = bytes.slice(bytes.length-len); 18 | } else while (len > bytes.length) { 19 | bytes.unshift(0); 20 | } 21 | return bytes; 22 | }; 23 | 24 | var x = this.getX().toBigInteger(); 25 | var y = this.getY().toBigInteger(); 26 | 27 | // Get value as a 32-byte Buffer 28 | // Fixed length based on a patch by bitaddress.org and Casascius 29 | var enc = integerToBytes(x, 32); 30 | 31 | if (compressed) { 32 | if (y.isEven()) { 33 | // Compressed even pubkey 34 | // M = 02 || X 35 | enc.unshift(0x02); 36 | } else { 37 | // Compressed uneven pubkey 38 | // M = 03 || X 39 | enc.unshift(0x03); 40 | } 41 | } else { 42 | // Uncompressed pubkey 43 | // M = 04 || X || Y 44 | enc.unshift(0x04); 45 | enc = enc.concat(integerToBytes(y, 32)); 46 | } 47 | return enc; 48 | }; 49 | 50 | ECPointFp.decodeFrom = function (curve, enc) { 51 | var type = enc[0]; 52 | var dataLen = enc.length-1; 53 | 54 | // Extract x and y as byte arrays 55 | var xBa = enc.slice(1, 1 + dataLen/2); 56 | var yBa = enc.slice(1 + dataLen/2, 1 + dataLen); 57 | 58 | // Prepend zero byte to prevent interpretation as negative integer 59 | xBa.unshift(0); 60 | yBa.unshift(0); 61 | 62 | // Convert to BigIntegers 63 | var x = new BigInteger(xBa); 64 | var y = new BigInteger(yBa); 65 | 66 | // Return point 67 | return new ECPointFp(curve, curve.fromBigInteger(x), curve.fromBigInteger(y)); 68 | }; 69 | 70 | /* 71 | * @since ec-patch.js 1.0.1 72 | */ 73 | ECPointFp.decodeFromHex = function (curve, encHex) { 74 | var type = encHex.substr(0, 2); // shall be "04" 75 | var dataLen = encHex.length - 2; 76 | 77 | // Extract x and y as byte arrays 78 | var xHex = encHex.substr(2, dataLen / 2); 79 | var yHex = encHex.substr(2 + dataLen / 2, dataLen / 2); 80 | 81 | // Convert to BigIntegers 82 | var x = new BigInteger(xHex, 16); 83 | var y = new BigInteger(yHex, 16); 84 | 85 | // Return point 86 | return new ECPointFp(curve, curve.fromBigInteger(x), curve.fromBigInteger(y)); 87 | }; 88 | 89 | ECPointFp.prototype.add2D = function (b) { 90 | if(this.isInfinity()) return b; 91 | if(b.isInfinity()) return this; 92 | 93 | if (this.x.equals(b.x)) { 94 | if (this.y.equals(b.y)) { 95 | // this = b, i.e. this must be doubled 96 | return this.twice(); 97 | } 98 | // this = -b, i.e. the result is the point at infinity 99 | return this.curve.getInfinity(); 100 | } 101 | 102 | var x_x = b.x.subtract(this.x); 103 | var y_y = b.y.subtract(this.y); 104 | var gamma = y_y.divide(x_x); 105 | 106 | var x3 = gamma.square().subtract(this.x).subtract(b.x); 107 | var y3 = gamma.multiply(this.x.subtract(x3)).subtract(this.y); 108 | 109 | return new ECPointFp(this.curve, x3, y3); 110 | }; 111 | 112 | ECPointFp.prototype.twice2D = function () { 113 | if (this.isInfinity()) return this; 114 | if (this.y.toBigInteger().signum() == 0) { 115 | // if y1 == 0, then (x1, y1) == (x1, -y1) 116 | // and hence this = -this and thus 2(x1, y1) == infinity 117 | return this.curve.getInfinity(); 118 | } 119 | 120 | var TWO = this.curve.fromBigInteger(BigInteger.valueOf(2)); 121 | var THREE = this.curve.fromBigInteger(BigInteger.valueOf(3)); 122 | var gamma = this.x.square().multiply(THREE).add(this.curve.a).divide(this.y.multiply(TWO)); 123 | 124 | var x3 = gamma.square().subtract(this.x.multiply(TWO)); 125 | var y3 = gamma.multiply(this.x.subtract(x3)).subtract(this.y); 126 | 127 | return new ECPointFp(this.curve, x3, y3); 128 | }; 129 | 130 | ECPointFp.prototype.multiply2D = function (k) { 131 | if(this.isInfinity()) return this; 132 | if(k.signum() == 0) return this.curve.getInfinity(); 133 | 134 | var e = k; 135 | var h = e.multiply(new BigInteger("3")); 136 | 137 | var neg = this.negate(); 138 | var R = this; 139 | 140 | var i; 141 | for (i = h.bitLength() - 2; i > 0; --i) { 142 | R = R.twice(); 143 | 144 | var hBit = h.testBit(i); 145 | var eBit = e.testBit(i); 146 | 147 | if (hBit != eBit) { 148 | R = R.add2D(hBit ? this : neg); 149 | } 150 | } 151 | 152 | return R; 153 | }; 154 | 155 | ECPointFp.prototype.isOnCurve = function () { 156 | var x = this.getX().toBigInteger(); 157 | var y = this.getY().toBigInteger(); 158 | var a = this.curve.getA().toBigInteger(); 159 | var b = this.curve.getB().toBigInteger(); 160 | var n = this.curve.getQ(); 161 | var lhs = y.multiply(y).mod(n); 162 | var rhs = x.multiply(x).multiply(x) 163 | .add(a.multiply(x)).add(b).mod(n); 164 | return lhs.equals(rhs); 165 | }; 166 | 167 | ECPointFp.prototype.toString = function () { 168 | return '('+this.getX().toBigInteger().toString()+','+ 169 | this.getY().toBigInteger().toString()+')'; 170 | }; 171 | 172 | /** 173 | * Validate an elliptic curve point. 174 | * 175 | * See SEC 1, section 3.2.2.1: Elliptic Curve Public Key Validation Primitive 176 | */ 177 | ECPointFp.prototype.validate = function () { 178 | var n = this.curve.getQ(); 179 | 180 | // Check Q != O 181 | if (this.isInfinity()) { 182 | throw new Error("Point is at infinity."); 183 | } 184 | 185 | // Check coordinate bounds 186 | var x = this.getX().toBigInteger(); 187 | var y = this.getY().toBigInteger(); 188 | if (x.compareTo(BigInteger.ONE) < 0 || 189 | x.compareTo(n.subtract(BigInteger.ONE)) > 0) { 190 | throw new Error('x coordinate out of bounds'); 191 | } 192 | if (y.compareTo(BigInteger.ONE) < 0 || 193 | y.compareTo(n.subtract(BigInteger.ONE)) > 0) { 194 | throw new Error('y coordinate out of bounds'); 195 | } 196 | 197 | // Check y^2 = x^3 + ax + b (mod n) 198 | if (!this.isOnCurve()) { 199 | throw new Error("Point is not on the curve."); 200 | } 201 | 202 | // Check nQ = 0 (Q is a scalar multiple of G) 203 | if (this.multiply(n).isInfinity()) { 204 | // TODO: This check doesn't work - fix. 205 | throw new Error("Point is not a scalar multiple of G."); 206 | } 207 | 208 | return true; 209 | }; 210 | -------------------------------------------------------------------------------- /jsrsasign/ext/prng4-min.js: -------------------------------------------------------------------------------- 1 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ 2 | */ 3 | function Arcfour(){this.i=0;this.j=0;this.S=new Array()}function ARC4init(d){var c,a,b;for(c=0;c<256;++c){this.S[c]=c}a=0;for(c=0;c<256;++c){a=(a+this.S[c]+d[c%d.length])&255;b=this.S[c];this.S[c]=this.S[a];this.S[a]=b}this.i=0;this.j=0}function ARC4next(){var a;this.i=(this.i+1)&255;this.j=(this.j+this.S[this.i])&255;a=this.S[this.i];this.S[this.i]=this.S[this.j];this.S[this.j]=a;return this.S[(a+this.S[this.i])&255]}Arcfour.prototype.init=ARC4init;Arcfour.prototype.next=ARC4next;function prng_newstate(){return new Arcfour()}var rng_psize=256; -------------------------------------------------------------------------------- /jsrsasign/ext/prng4.js: -------------------------------------------------------------------------------- 1 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ 2 | */ 3 | // prng4.js - uses Arcfour as a PRNG 4 | 5 | function Arcfour() { 6 | this.i = 0; 7 | this.j = 0; 8 | this.S = new Array(); 9 | } 10 | 11 | // Initialize arcfour context from key, an array of ints, each from [0..255] 12 | function ARC4init(key) { 13 | var i, j, t; 14 | for(i = 0; i < 256; ++i) 15 | this.S[i] = i; 16 | j = 0; 17 | for(i = 0; i < 256; ++i) { 18 | j = (j + this.S[i] + key[i % key.length]) & 255; 19 | t = this.S[i]; 20 | this.S[i] = this.S[j]; 21 | this.S[j] = t; 22 | } 23 | this.i = 0; 24 | this.j = 0; 25 | } 26 | 27 | function ARC4next() { 28 | var t; 29 | this.i = (this.i + 1) & 255; 30 | this.j = (this.j + this.S[this.i]) & 255; 31 | t = this.S[this.i]; 32 | this.S[this.i] = this.S[this.j]; 33 | this.S[this.j] = t; 34 | return this.S[(t + this.S[this.i]) & 255]; 35 | } 36 | 37 | Arcfour.prototype.init = ARC4init; 38 | Arcfour.prototype.next = ARC4next; 39 | 40 | // Plug in your RNG constructor here 41 | function prng_newstate() { 42 | return new Arcfour(); 43 | } 44 | 45 | // Pool size must be a multiple of 4 and greater than 32. 46 | // An array of bytes the size of the pool will be passed to init() 47 | var rng_psize = 256; 48 | -------------------------------------------------------------------------------- /jsrsasign/ext/rng-min.js: -------------------------------------------------------------------------------- 1 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ 2 | */ 3 | var rng_state;var rng_pool;var rng_pptr;function rng_seed_int(a){rng_pool[rng_pptr++]^=a&255;rng_pool[rng_pptr++]^=(a>>8)&255;rng_pool[rng_pptr++]^=(a>>16)&255;rng_pool[rng_pptr++]^=(a>>24)&255;if(rng_pptr>=rng_psize){rng_pptr-=rng_psize}}function rng_seed_time(){rng_seed_int(new Date().getTime())}if(rng_pool==null){rng_pool=new Array();rng_pptr=0;var t;if(navigator.appName=="Netscape"&&navigator.appVersion<"5"&&window.crypto){var z=window.crypto.random(32);for(t=0;t>>8;rng_pool[rng_pptr++]=t&255}rng_pptr=0;rng_seed_time()}function rng_get_byte(){if(rng_state==null){rng_seed_time();rng_state=prng_newstate();rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr 7 | // in your main HTML document. 8 | 9 | var rng_state; 10 | var rng_pool; 11 | var rng_pptr; 12 | 13 | // Mix in a 32-bit integer into the pool 14 | function rng_seed_int(x) { 15 | rng_pool[rng_pptr++] ^= x & 255; 16 | rng_pool[rng_pptr++] ^= (x >> 8) & 255; 17 | rng_pool[rng_pptr++] ^= (x >> 16) & 255; 18 | rng_pool[rng_pptr++] ^= (x >> 24) & 255; 19 | if(rng_pptr >= rng_psize) rng_pptr -= rng_psize; 20 | } 21 | 22 | // Mix in the current time (w/milliseconds) into the pool 23 | function rng_seed_time() { 24 | rng_seed_int(new Date().getTime()); 25 | } 26 | 27 | // Initialize the pool with junk if needed. 28 | if(rng_pool == null) { 29 | rng_pool = new Array(); 30 | rng_pptr = 0; 31 | var t; 32 | if(navigator.appName == "Netscape" && navigator.appVersion < "5" && window.crypto) { 33 | // Extract entropy (256 bits) from NS4 RNG if available 34 | var z = window.crypto.random(32); 35 | for(t = 0; t < z.length; ++t) 36 | rng_pool[rng_pptr++] = z.charCodeAt(t) & 255; 37 | } 38 | while(rng_pptr < rng_psize) { // extract some randomness from Math.random() 39 | t = Math.floor(65536 * Math.random()); 40 | rng_pool[rng_pptr++] = t >>> 8; 41 | rng_pool[rng_pptr++] = t & 255; 42 | } 43 | rng_pptr = 0; 44 | rng_seed_time(); 45 | //rng_seed_int(window.screenX); 46 | //rng_seed_int(window.screenY); 47 | } 48 | 49 | function rng_get_byte() { 50 | if(rng_state == null) { 51 | rng_seed_time(); 52 | rng_state = prng_newstate(); 53 | rng_state.init(rng_pool); 54 | for(rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) 55 | rng_pool[rng_pptr] = 0; 56 | rng_pptr = 0; 57 | //rng_pool = null; 58 | } 59 | // TODO: allow reseeding after first request 60 | return rng_state.next(); 61 | } 62 | 63 | function rng_get_bytes(ba) { 64 | var i; 65 | for(i = 0; i < ba.length; ++i) ba[i] = rng_get_byte(); 66 | } 67 | 68 | function SecureRandom() {} 69 | 70 | SecureRandom.prototype.nextBytes = rng_get_bytes; 71 | -------------------------------------------------------------------------------- /jsrsasign/ext/rsa-min.js: -------------------------------------------------------------------------------- 1 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ 2 | */ 3 | function parseBigInt(b,a){return new BigInteger(b,a)}function linebrk(c,d){var a="";var b=0;while(b+d=0&&h>0){var f=e.charCodeAt(d--);if(f<128){g[--h]=f}else{if((f>127)&&(f<2048)){g[--h]=(f&63)|128;g[--h]=(f>>6)|192}else{g[--h]=(f&63)|128;g[--h]=((f>>6)&63)|128;g[--h]=(f>>12)|224}}}g[--h]=0;var b=new SecureRandom();var a=new Array();while(h>2){a[0]=0;while(a[0]==0){b.nextBytes(a)}g[--h]=a[0]}g[--h]=2;g[--h]=0;return new BigInteger(g)}function oaep_mgf1_arr(c,a,e){var b="",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255])));d+=1}return b}var SHA1_SIZE=20;function oaep_pad(l,a,c){if(l.length+2*SHA1_SIZE+2>a){throw"Message too long for RSA"}var h="",d;for(d=0;d0&&a.length>0){this.n=parseBigInt(b,16);this.e=parseInt(a,16)}else{alert("Invalid RSA public key")}}}function RSADoPublic(a){return a.modPowInt(this.e,this.n)}function RSAEncrypt(d){var a=pkcs1pad2(d,(this.n.bitLength()+7)>>3);if(a==null){return null}var e=this.doPublic(a);if(e==null){return null}var b=e.toString(16);if((b.length&1)==0){return b}else{return"0"+b}}function RSAEncryptOAEP(e,d){var a=oaep_pad(e,(this.n.bitLength()+7)>>3,d);if(a==null){return null}var f=this.doPublic(a);if(f==null){return null}var b=f.toString(16);if((b.length&1)==0){return b}else{return"0"+b}}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt;RSAKey.prototype.encryptOAEP=RSAEncryptOAEP;RSAKey.prototype.type="RSA"; -------------------------------------------------------------------------------- /jsrsasign/ext/rsa.js: -------------------------------------------------------------------------------- 1 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ 2 | */ 3 | // Depends on jsbn.js and rng.js 4 | 5 | // Version 1.1: support utf-8 encoding in pkcs1pad2 6 | 7 | // convert a (hex) string to a bignum object 8 | function parseBigInt(str,r) { 9 | return new BigInteger(str,r); 10 | } 11 | 12 | function linebrk(s,n) { 13 | var ret = ""; 14 | var i = 0; 15 | while(i + n < s.length) { 16 | ret += s.substring(i,i+n) + "\n"; 17 | i += n; 18 | } 19 | return ret + s.substring(i,s.length); 20 | } 21 | 22 | function byte2Hex(b) { 23 | if(b < 0x10) 24 | return "0" + b.toString(16); 25 | else 26 | return b.toString(16); 27 | } 28 | 29 | // PKCS#1 (type 2, random) pad input string s to n bytes, and return a bigint 30 | function pkcs1pad2(s,n) { 31 | if(n < s.length + 11) { // TODO: fix for utf-8 32 | alert("Message too long for RSA"); 33 | return null; 34 | } 35 | var ba = new Array(); 36 | var i = s.length - 1; 37 | while(i >= 0 && n > 0) { 38 | var c = s.charCodeAt(i--); 39 | if(c < 128) { // encode using utf-8 40 | ba[--n] = c; 41 | } 42 | else if((c > 127) && (c < 2048)) { 43 | ba[--n] = (c & 63) | 128; 44 | ba[--n] = (c >> 6) | 192; 45 | } 46 | else { 47 | ba[--n] = (c & 63) | 128; 48 | ba[--n] = ((c >> 6) & 63) | 128; 49 | ba[--n] = (c >> 12) | 224; 50 | } 51 | } 52 | ba[--n] = 0; 53 | var rng = new SecureRandom(); 54 | var x = new Array(); 55 | while(n > 2) { // random non-zero pad 56 | x[0] = 0; 57 | while(x[0] == 0) rng.nextBytes(x); 58 | ba[--n] = x[0]; 59 | } 60 | ba[--n] = 2; 61 | ba[--n] = 0; 62 | return new BigInteger(ba); 63 | } 64 | 65 | // PKCS#1 (OAEP) mask generation function 66 | function oaep_mgf1_arr(seed, len, hash) 67 | { 68 | var mask = '', i = 0; 69 | 70 | while (mask.length < len) 71 | { 72 | mask += hash(String.fromCharCode.apply(String, seed.concat([ 73 | (i & 0xff000000) >> 24, 74 | (i & 0x00ff0000) >> 16, 75 | (i & 0x0000ff00) >> 8, 76 | i & 0x000000ff]))); 77 | i += 1; 78 | } 79 | 80 | return mask; 81 | } 82 | 83 | var SHA1_SIZE = 20; 84 | 85 | // PKCS#1 (OAEP) pad input string s to n bytes, and return a bigint 86 | function oaep_pad(s, n, hash) 87 | { 88 | if (s.length + 2 * SHA1_SIZE + 2 > n) 89 | { 90 | throw "Message too long for RSA"; 91 | } 92 | 93 | var PS = '', i; 94 | 95 | for (i = 0; i < n - s.length - 2 * SHA1_SIZE - 2; i += 1) 96 | { 97 | PS += '\x00'; 98 | } 99 | 100 | var DB = rstr_sha1('') + PS + '\x01' + s; 101 | var seed = new Array(SHA1_SIZE); 102 | new SecureRandom().nextBytes(seed); 103 | 104 | var dbMask = oaep_mgf1_arr(seed, DB.length, hash || rstr_sha1); 105 | var maskedDB = []; 106 | 107 | for (i = 0; i < DB.length; i += 1) 108 | { 109 | maskedDB[i] = DB.charCodeAt(i) ^ dbMask.charCodeAt(i); 110 | } 111 | 112 | var seedMask = oaep_mgf1_arr(maskedDB, seed.length, rstr_sha1); 113 | var maskedSeed = [0]; 114 | 115 | for (i = 0; i < seed.length; i += 1) 116 | { 117 | maskedSeed[i + 1] = seed[i] ^ seedMask.charCodeAt(i); 118 | } 119 | 120 | return new BigInteger(maskedSeed.concat(maskedDB)); 121 | } 122 | 123 | // "empty" RSA key constructor 124 | function RSAKey() { 125 | this.n = null; 126 | this.e = 0; 127 | this.d = null; 128 | this.p = null; 129 | this.q = null; 130 | this.dmp1 = null; 131 | this.dmq1 = null; 132 | this.coeff = null; 133 | } 134 | 135 | // Set the public key fields N and e from hex strings 136 | function RSASetPublic(N,E) { 137 | this.isPublic = true; 138 | if (typeof N !== "string") 139 | { 140 | this.n = N; 141 | this.e = E; 142 | } 143 | else if(N != null && E != null && N.length > 0 && E.length > 0) { 144 | this.n = parseBigInt(N,16); 145 | this.e = parseInt(E,16); 146 | } 147 | else 148 | alert("Invalid RSA public key"); 149 | } 150 | 151 | // Perform raw public operation on "x": return x^e (mod n) 152 | function RSADoPublic(x) { 153 | return x.modPowInt(this.e, this.n); 154 | } 155 | 156 | // Return the PKCS#1 RSA encryption of "text" as an even-length hex string 157 | function RSAEncrypt(text) { 158 | var m = pkcs1pad2(text,(this.n.bitLength()+7)>>3); 159 | if(m == null) return null; 160 | var c = this.doPublic(m); 161 | if(c == null) return null; 162 | var h = c.toString(16); 163 | if((h.length & 1) == 0) return h; else return "0" + h; 164 | } 165 | 166 | // Return the PKCS#1 OAEP RSA encryption of "text" as an even-length hex string 167 | function RSAEncryptOAEP(text, hash) { 168 | var m = oaep_pad(text, (this.n.bitLength()+7)>>3, hash); 169 | if(m == null) return null; 170 | var c = this.doPublic(m); 171 | if(c == null) return null; 172 | var h = c.toString(16); 173 | if((h.length & 1) == 0) return h; else return "0" + h; 174 | } 175 | 176 | // Return the PKCS#1 RSA encryption of "text" as a Base64-encoded string 177 | //function RSAEncryptB64(text) { 178 | // var h = this.encrypt(text); 179 | // if(h) return hex2b64(h); else return null; 180 | //} 181 | 182 | // protected 183 | RSAKey.prototype.doPublic = RSADoPublic; 184 | 185 | // public 186 | RSAKey.prototype.setPublic = RSASetPublic; 187 | RSAKey.prototype.encrypt = RSAEncrypt; 188 | RSAKey.prototype.encryptOAEP = RSAEncryptOAEP; 189 | //RSAKey.prototype.encrypt_b64 = RSAEncryptB64; 190 | 191 | RSAKey.prototype.type = "RSA"; 192 | -------------------------------------------------------------------------------- /jsrsasign/ext/rsa2-min.js: -------------------------------------------------------------------------------- 1 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ 2 | */ 3 | function pkcs1unpad2(g,j){var a=g.toByteArray();var f=0;while(f=a.length){return null}}var e="";while(++f191)&&(h<224)){e+=String.fromCharCode(((h&31)<<6)|(a[f+1]&63));++f}else{e+=String.fromCharCode(((h&15)<<12)|((a[f+1]&63)<<6)|(a[f+2]&63));f+=2}}}return e}function oaep_mgf1_str(c,a,e){var b="",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255]));d+=1}return b}var SHA1_SIZE=20;function oaep_unpad(l,b,e){l=l.toByteArray();var f;for(f=0;f0&&a.length>0){this.n=parseBigInt(c,16);this.e=parseInt(a,16);this.d=parseBigInt(b,16)}else{alert("Invalid RSA private key")}}}function RSASetPrivateEx(g,d,e,c,b,a,h,f){this.isPrivate=true;if(g==null){throw"RSASetPrivateEx N == null"}if(d==null){throw"RSASetPrivateEx E == null"}if(g.length==0){throw"RSASetPrivateEx N.length == 0"}if(d.length==0){throw"RSASetPrivateEx E.length == 0"}if(g!=null&&d!=null&&g.length>0&&d.length>0){this.n=parseBigInt(g,16);this.e=parseInt(d,16);this.d=parseBigInt(e,16);this.p=parseBigInt(c,16);this.q=parseBigInt(b,16);this.dmp1=parseBigInt(a,16);this.dmq1=parseBigInt(h,16);this.coeff=parseBigInt(f,16)}else{alert("Invalid RSA private key in RSASetPrivateEx")}}function RSAGenerate(b,i){var a=new SecureRandom();var f=b>>1;this.e=parseInt(i,16);var c=new BigInteger(i,16);for(;;){for(;;){this.p=new BigInteger(b-f,1,a);if(this.p.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.p.isProbablePrime(10)){break}}for(;;){this.q=new BigInteger(f,1,a);if(this.q.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.q.isProbablePrime(10)){break}}if(this.p.compareTo(this.q)<=0){var h=this.p;this.p=this.q;this.q=h}var g=this.p.subtract(BigInteger.ONE);var d=this.q.subtract(BigInteger.ONE);var e=g.multiply(d);if(e.gcd(c).compareTo(BigInteger.ONE)==0){this.n=this.p.multiply(this.q);this.d=c.modInverse(e);this.dmp1=this.d.mod(g);this.dmq1=this.d.mod(d);this.coeff=this.q.modInverse(this.p);break}}}function RSADoPrivate(a){if(this.p==null||this.q==null){return a.modPow(this.d,this.n)}var c=a.mod(this.p).modPow(this.dmp1,this.p);var b=a.mod(this.q).modPow(this.dmq1,this.q);while(c.compareTo(b)<0){c=c.add(this.p)}return c.subtract(b).multiply(this.coeff).mod(this.p).multiply(this.q).add(b)}function RSADecrypt(b){var d=parseBigInt(b,16);var a=this.doPrivate(d);if(a==null){return null}return pkcs1unpad2(a,(this.n.bitLength()+7)>>3)}function RSADecryptOAEP(d,b){var e=parseBigInt(d,16);var a=this.doPrivate(e);if(a==null){return null}return oaep_unpad(a,(this.n.bitLength()+7)>>3,b)}RSAKey.prototype.doPrivate=RSADoPrivate;RSAKey.prototype.setPrivate=RSASetPrivate;RSAKey.prototype.setPrivateEx=RSASetPrivateEx;RSAKey.prototype.generate=RSAGenerate;RSAKey.prototype.decrypt=RSADecrypt;RSAKey.prototype.decryptOAEP=RSADecryptOAEP; -------------------------------------------------------------------------------- /jsrsasign/index_ut.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | jsrsasign Unit Tests 11 | 12 | 13 | 14 | 15 |
16 |
17 |

jsrsasign Unit Tests

18 | TOP | 19 | DOWNLOADS | 20 | TUTORIALS | 21 | API REFERENCE | 22 | DEMOS | 23 |
24 |
25 | 26 | 27 |
28 |
29 | 30 | 31 |

Unit Tests

32 | Unit tests for jsrsasign are done using QUnit framework. 33 | This may be useful for examples to learn 'jsrsasign' library. 34 | 54 | 55 | Back to TOP. 56 | 57 | 58 | 59 |
60 |
61 | 62 | 63 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /jsrsasign/npm/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | echo aaa 3 | 4 | aaa: 5 | cat \ 6 | lib/header.js \ 7 | ../jsrsasign-latest-all-min.js \ 8 | ../../../../jsjws/_gitpg/jsjws/ext/json-sans-eval-min.js \ 9 | ../../../../jsjws/_gitpg/jsjws/jws-3.0.min.js \ 10 | ../../../../jsjws/_gitpg/jsjws/jwsjs-2.0.min.js \ 11 | lib/footer.js \ 12 | > lib/jsrsasign.js 13 | 14 | -------------------------------------------------------------------------------- /jsrsasign/npm/README.md: -------------------------------------------------------------------------------- 1 | jsrsasign 2 | ========= 3 | 4 | The 'jsrsasign' (RSA-Sign JavaScript Library) is an opensource free pure JavaScript cryptographic library supports RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate and CRL 5 | 6 | Public page is http://kjur.github.com/jsrsasign . 7 | 8 | Your bugfix and pull request contribution are always welcomed :) 9 | 10 | DIFFERENCE WITH CRYPTO MODULE 11 | ----------------------------- 12 | 13 | Here is the difference between bundled ['Crypto' module](http://nodejs.org/api/crypto.html) 14 | and this 'jsrsasign' module. 15 | 16 | - Crypto module 17 | - fast 18 | - works only on Node.js 19 | - OpenSSL based 20 | - lacking ASN.1 functionality 21 | - provides symmetric ciphers 22 | - lacking RSAPSS signing 23 | - jsrsasign module 24 | - slow 25 | - implemented in pure JavaScript 26 | - works on both Node.js(server) and browsers(client) 27 | - provides ASN.1 parsing/generation functionality 28 | - lacking symmetric ciphers 29 | - provides RSAPSS signing 30 | - also provides support for JSON Web Signatures (JWS) and JSON Web Token (JWT) 31 | 32 | CONCLUDED THRIDPARTY LIBRARIES 33 | ------------------------------ 34 | 35 | - [CryptoJS](https://code.google.com/p/crypto-js/): for symmetric cipher, hash, mac, PBKDF (BSD License) 36 | - [BitCoinJS](http://bitcoinjs.org/): for ECDSA (MIT License) 37 | - [OpenPGP.js](http://openpgpjs.org/): for DSA (LGPL License) 38 | - [Tom Wu's jsbn](http://www-cs-students.stanford.edu/~tjw/jsbn/): for BigInteger, RSA encryption and EC (BSD License) 39 | - [Yahoo YUI](http://yuilibrary.com/): for class inheritance (BSD License) 40 | - [json-sans-eval](https://code.google.com/p/json-sans-eval/): secure JSON parser (Apache License) 41 | 42 | AVAILABLE CLASSES AND METHODS 43 | ----------------------------- 44 | 45 | Most of the classes and methods defined in jsrsasign and jsjws are 46 | available in this jsrsasign npm module. 47 | 48 | After loading the module, 49 | 50 | > var r = require('jsrsasign'); 51 | 52 | You can refer name spaces, classes, methods and functions 53 | by following variables: 54 | 55 | - r.BigInteger - BigInteger class 56 | - r.RSAKey - [RSAKey class](http://kjur.github.io/jsrsasign/api/symbols/RSAKey.html) 57 | - r.ECDSA - [KJUR.crypto.ECDSA class](http://kjur.github.io/jsrsasign/api/symbols/KJUR.crypto.ECDSA.html) 58 | - r.DSA - [KJUR.crypto.DSA class](http://kjur.github.io/jsrsasign/api/symbols/KJUR.crypto.DSA.html) 59 | - r.Signature - [KJUR.crypto.Signature class](http://kjur.github.io/jsrsasign/api/symbols/KJUR.crypto.Signature.html) 60 | - r.MessageDigest - [KJUR.crypto.MessageDigest class](http://kjur.github.io/jsrsasign/api/symbols/KJUR.crypto.MessageDigest.html) 61 | - r.Mac - [KJUR.crypto.Mac class](http://kjur.github.io/jsrsasign/api/symbols/KJUR.crypto.Mac.html) 62 | - r.KEYUTIL - [KEYUTIL class](http://kjur.github.io/jsrsasign/api/symbols/KEYUTIL.html) 63 | - r.ASN1HEX - [ASN1HEX class](http://kjur.github.io/jsrsasign/api/symbols/ASN1HEX.html) 64 | - r.crypto - [KJUR.crypto name space](http://kjur.github.io/jsrsasign/api/symbols/KJUR.crypto.html) 65 | - r.asn1 - [KJUR.asn1 name space](http://kjur.github.io/jsrsasign/api/symbols/KJUR.asn1.html) 66 | - r.jws - [KJUR.jws name space](http://kjur.github.io/jsjws/api/) 67 | 68 | Please see API reference in the above links. 69 | 70 | EXAMPLE(1) SIGNATURE 71 | -------------------- 72 | 73 | Loading encrypted PKCS#5 private key: 74 | 75 | > var fs = require('fs'); 76 | > var pem = fs.readFileSync('z1.prv.p5e.pem', 'binary'); 77 | > var prvKey = a.KEYUTIL.getKey(pem, 'passwd'); 78 | 79 | Sign string 'aaa' with the loaded private key: 80 | 81 | > var sig = new a.Signature({alg: 'SHA1withRSA'}); 82 | > sig.init(prvKey); 83 | > sig.updateString('aaa'); 84 | > var sigVal = sig.sign(); 85 | > sigVal 86 | 'd764dcacb...' 87 | 88 | 89 | -------------------------------------------------------------------------------- /jsrsasign/npm/lib/footer.js: -------------------------------------------------------------------------------- 1 | 2 | exports.BigInteger = BigInteger; 3 | exports.RSAKey = RSAKey; 4 | exports.ECDSA = KJUR.crypto.ECDSA; 5 | exports.DSA = KJUR.crypto.DSA; 6 | exports.Signature = KJUR.crypto.Signature; 7 | exports.MessageDigest = KJUR.crypto.MessageDigest; 8 | exports.Mac = KJUR.crypto.Mac; 9 | exports.KEYUTIL = KEYUTIL; 10 | exports.ASN1HEX = ASN1HEX; 11 | 12 | // ext/base64.js 13 | exports.b64tohex = b64tohex; 14 | exports.b64tohex = b64toBA; 15 | 16 | // base64x.js 17 | exports.stoBA = stoBA; 18 | exports.stoBA = BAtos; 19 | exports.stoBA = BAtohex; 20 | exports.stohex = stohex; 21 | exports.stob64 = stob64; 22 | exports.stob64u = stob64u; 23 | exports.b64utos = b64utos; 24 | exports.b64tob64u = b64tob64u; 25 | exports.b64utob64 = b64utob64; 26 | exports.hextob64u = hextob64u; 27 | exports.b64utohex = b64utohex; 28 | exports.b64tohex = b64tohex; 29 | exports.utf8tob64u = utf8tob64u; 30 | exports.b64utoutf8 = b64utoutf8; 31 | exports.utf8tob64 = utf8tob64; 32 | exports.b64toutf8 = b64toutf8; 33 | exports.utf8tohex = utf8tohex; 34 | exports.hextoutf8 = hextoutf8; 35 | exports.hextorstr = hextorstr; 36 | exports.rstrtohex = rstrtohex; 37 | exports.newline_toUnix = newline_toUnix; 38 | exports.newline_toDos = newline_toDos; 39 | 40 | exports.crypto = KJUR.crypto; 41 | exports.asn1 = KJUR.asn1; 42 | exports.jws = KJUR.jws; 43 | -------------------------------------------------------------------------------- /jsrsasign/npm/lib/header.js: -------------------------------------------------------------------------------- 1 | 2 | var navigator = {}; 3 | navigator.uesrAgent = false; 4 | 5 | var window = {}; 6 | -------------------------------------------------------------------------------- /jsrsasign/npm/lib/lib.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phelipealves/assinaturadigitaljavascript/40cf3b05ff14d0a7316a9ec2f651c0f4266429e6/jsrsasign/npm/lib/lib.js -------------------------------------------------------------------------------- /jsrsasign/npm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jsrsasign", 3 | "version": "0.0.3", 4 | "description": "pure JavaScript cryptographic library(jsrsasign) and JSON Web Token (JWT) and JSON Web Signature (JWS) library (jsjws) bundle", 5 | "main": "lib/jsrsasign.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/kjur/jsrsasign.git" 12 | }, 13 | "keywords": [ 14 | "RSA", 15 | "ECDSA", 16 | "DSA", 17 | "RSAPSS", 18 | "PKCS1", 19 | "PKCS5", 20 | "PKCS8", 21 | "hash function", 22 | "HMac", 23 | "ASN.1", 24 | "X.509", 25 | "Signature", 26 | "Message Digest", 27 | "signing", 28 | "certificate", 29 | "JSON Web Token", 30 | "JSON Web Signature", 31 | "JWT", 32 | "JWS", 33 | "JOSE", 34 | "JWA" 35 | ], 36 | "author": "Kenji Urushima", 37 | "licenses": [ 38 | { 39 | "type": "MIT", 40 | "url": "https://raw.github.com/kjur/jsrsasign/master/LICENSE.txt" 41 | } 42 | ], 43 | "bugs": { 44 | "url": "https://github.com/kjur/jsrsasign/issues" 45 | }, 46 | "dependencies": {} 47 | } 48 | -------------------------------------------------------------------------------- /jsrsasign/rsapem-1.1.js: -------------------------------------------------------------------------------- 1 | /*! rsapem-1.1.js (c) 2012 Kenji Urushima | kjur.github.com/jsrsasign/license 2 | */ 3 | // 4 | // rsa-pem.js - adding function for reading/writing PKCS#1 PEM private key 5 | // to RSAKey class. 6 | // 7 | // version: 1.1.1 (2013-Apr-12) 8 | // 9 | // Copyright (c) 2010-2013 Kenji Urushima (kenji.urushima@gmail.com) 10 | // 11 | // This software is licensed under the terms of the MIT License. 12 | // http://kjur.github.com/jsrsasign/license/ 13 | // 14 | // The above copyright and license notice shall be 15 | // included in all copies or substantial portions of the Software. 16 | // 17 | // 18 | // Depends on: 19 | // 20 | // 21 | // 22 | // _RSApem_pemToBase64(sPEM) 23 | // 24 | // removing PEM header, PEM footer and space characters including 25 | // new lines from PEM formatted RSA private key string. 26 | // 27 | 28 | /** 29 | * @fileOverview 30 | * @name rsapem-1.1.js 31 | * @author Kenji Urushima kenji.urushima@gmail.com 32 | * @version 1.1 33 | * @license MIT License 34 | */ 35 | function _rsapem_pemToBase64(sPEMPrivateKey) { 36 | var s = sPEMPrivateKey; 37 | s = s.replace("-----BEGIN RSA PRIVATE KEY-----", ""); 38 | s = s.replace("-----END RSA PRIVATE KEY-----", ""); 39 | s = s.replace(/[ \n]+/g, ""); 40 | return s; 41 | } 42 | 43 | function _rsapem_getPosArrayOfChildrenFromHex(hPrivateKey) { 44 | var a = new Array(); 45 | var v1 = ASN1HEX.getStartPosOfV_AtObj(hPrivateKey, 0); 46 | var n1 = ASN1HEX.getPosOfNextSibling_AtObj(hPrivateKey, v1); 47 | var e1 = ASN1HEX.getPosOfNextSibling_AtObj(hPrivateKey, n1); 48 | var d1 = ASN1HEX.getPosOfNextSibling_AtObj(hPrivateKey, e1); 49 | var p1 = ASN1HEX.getPosOfNextSibling_AtObj(hPrivateKey, d1); 50 | var q1 = ASN1HEX.getPosOfNextSibling_AtObj(hPrivateKey, p1); 51 | var dp1 = ASN1HEX.getPosOfNextSibling_AtObj(hPrivateKey, q1); 52 | var dq1 = ASN1HEX.getPosOfNextSibling_AtObj(hPrivateKey, dp1); 53 | var co1 = ASN1HEX.getPosOfNextSibling_AtObj(hPrivateKey, dq1); 54 | a.push(v1, n1, e1, d1, p1, q1, dp1, dq1, co1); 55 | return a; 56 | } 57 | 58 | function _rsapem_getHexValueArrayOfChildrenFromHex(hPrivateKey) { 59 | var posArray = _rsapem_getPosArrayOfChildrenFromHex(hPrivateKey); 60 | var v = ASN1HEX.getHexOfV_AtObj(hPrivateKey, posArray[0]); 61 | var n = ASN1HEX.getHexOfV_AtObj(hPrivateKey, posArray[1]); 62 | var e = ASN1HEX.getHexOfV_AtObj(hPrivateKey, posArray[2]); 63 | var d = ASN1HEX.getHexOfV_AtObj(hPrivateKey, posArray[3]); 64 | var p = ASN1HEX.getHexOfV_AtObj(hPrivateKey, posArray[4]); 65 | var q = ASN1HEX.getHexOfV_AtObj(hPrivateKey, posArray[5]); 66 | var dp = ASN1HEX.getHexOfV_AtObj(hPrivateKey, posArray[6]); 67 | var dq = ASN1HEX.getHexOfV_AtObj(hPrivateKey, posArray[7]); 68 | var co = ASN1HEX.getHexOfV_AtObj(hPrivateKey, posArray[8]); 69 | var a = new Array(); 70 | a.push(v, n, e, d, p, q, dp, dq, co); 71 | return a; 72 | } 73 | 74 | /** 75 | * read RSA private key from a ASN.1 hexadecimal string 76 | * @name readPrivateKeyFromASN1HexString 77 | * @memberOf RSAKey# 78 | * @function 79 | * @param {String} keyHex ASN.1 hexadecimal string of PKCS#1 private key. 80 | * @since 1.1.1 81 | */ 82 | function _rsapem_readPrivateKeyFromASN1HexString(keyHex) { 83 | var a = _rsapem_getHexValueArrayOfChildrenFromHex(keyHex); 84 | this.setPrivateEx(a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8]); 85 | } 86 | 87 | /** 88 | * read PKCS#1 private key from a string 89 | * @name readPrivateKeyFromPEMString 90 | * @memberOf RSAKey# 91 | * @function 92 | * @param {String} keyPEM string of PKCS#1 private key. 93 | */ 94 | function _rsapem_readPrivateKeyFromPEMString(keyPEM) { 95 | var keyB64 = _rsapem_pemToBase64(keyPEM); 96 | var keyHex = b64tohex(keyB64) // depends base64.js 97 | var a = _rsapem_getHexValueArrayOfChildrenFromHex(keyHex); 98 | this.setPrivateEx(a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8]); 99 | } 100 | 101 | RSAKey.prototype.readPrivateKeyFromPEMString = _rsapem_readPrivateKeyFromPEMString; 102 | RSAKey.prototype.readPrivateKeyFromASN1HexString = _rsapem_readPrivateKeyFromASN1HexString; 103 | -------------------------------------------------------------------------------- /jsrsasign/rsapem-1.1.min.js: -------------------------------------------------------------------------------- 1 | /*! rsapem-1.1.js (c) 2012 Kenji Urushima | kjur.github.com/jsrsasign/license 2 | */ 3 | function _rsapem_pemToBase64(b){var a=b;a=a.replace("-----BEGIN RSA PRIVATE KEY-----","");a=a.replace("-----END RSA PRIVATE KEY-----","");a=a.replace(/[ \n]+/g,"");return a}function _rsapem_getPosArrayOfChildrenFromHex(d){var j=new Array();var k=ASN1HEX.getStartPosOfV_AtObj(d,0);var f=ASN1HEX.getPosOfNextSibling_AtObj(d,k);var h=ASN1HEX.getPosOfNextSibling_AtObj(d,f);var b=ASN1HEX.getPosOfNextSibling_AtObj(d,h);var l=ASN1HEX.getPosOfNextSibling_AtObj(d,b);var e=ASN1HEX.getPosOfNextSibling_AtObj(d,l);var g=ASN1HEX.getPosOfNextSibling_AtObj(d,e);var c=ASN1HEX.getPosOfNextSibling_AtObj(d,g);var i=ASN1HEX.getPosOfNextSibling_AtObj(d,c);j.push(k,f,h,b,l,e,g,c,i);return j}function _rsapem_getHexValueArrayOfChildrenFromHex(i){var o=_rsapem_getPosArrayOfChildrenFromHex(i);var r=ASN1HEX.getHexOfV_AtObj(i,o[0]);var f=ASN1HEX.getHexOfV_AtObj(i,o[1]);var j=ASN1HEX.getHexOfV_AtObj(i,o[2]);var k=ASN1HEX.getHexOfV_AtObj(i,o[3]);var c=ASN1HEX.getHexOfV_AtObj(i,o[4]);var b=ASN1HEX.getHexOfV_AtObj(i,o[5]);var h=ASN1HEX.getHexOfV_AtObj(i,o[6]);var g=ASN1HEX.getHexOfV_AtObj(i,o[7]);var l=ASN1HEX.getHexOfV_AtObj(i,o[8]);var m=new Array();m.push(r,f,j,k,c,b,h,g,l);return m}function _rsapem_readPrivateKeyFromASN1HexString(c){var b=_rsapem_getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])}function _rsapem_readPrivateKeyFromPEMString(e){var c=_rsapem_pemToBase64(e);var d=b64tohex(c);var b=_rsapem_getHexValueArrayOfChildrenFromHex(d);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])}RSAKey.prototype.readPrivateKeyFromPEMString=_rsapem_readPrivateKeyFromPEMString;RSAKey.prototype.readPrivateKeyFromASN1HexString=_rsapem_readPrivateKeyFromASN1HexString; -------------------------------------------------------------------------------- /jsrsasign/rsasign-1.2.min.js: -------------------------------------------------------------------------------- 1 | /*! rsasign-1.2.7.js (c) 2012 Kenji Urushima | kjur.github.com/jsrsasign/license 2 | */ 3 | var _RE_HEXDECONLY=new RegExp("");_RE_HEXDECONLY.compile("[^0-9a-f]","gi");function _rsasign_getHexPaddedDigestInfoForString(d,e,a){var b=function(f){return KJUR.crypto.Util.hashString(f,a)};var c=b(d);return KJUR.crypto.Util.getPaddedDigestInfoHex(c,a,e)}function _zeroPaddingOfSignature(e,d){var c="";var a=d/4-e.length;for(var b=0;b>24,(d&16711680)>>16,(d&65280)>>8,d&255]))));d+=1}return b}function _rsasign_signStringPSS(e,a,d){var c=function(f){return KJUR.crypto.Util.hashHex(f,a)};var b=c(rstrtohex(e));if(d===undefined){d=-1}return this.signWithMessageHashPSS(b,a,d)}function _rsasign_signWithMessageHashPSS(l,a,k){var b=hextorstr(l);var g=b.length;var m=this.n.bitLength()-1;var c=Math.ceil(m/8);var d;var o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(k===-1||k===undefined){k=g}else{if(k===-2){k=c-g-2}else{if(k<-2){throw"invalid salt length"}}}if(c<(g+k+2)){throw"data too long"}var f="";if(k>0){f=new Array(k);new SecureRandom().nextBytes(f);f=String.fromCharCode.apply(String,f)}var n=hextorstr(o(rstrtohex("\x00\x00\x00\x00\x00\x00\x00\x00"+b+f)));var j=[];for(d=0;d>(8*c-m))&255;q[0]&=~p;for(d=0;dthis.n.bitLength()){return 0}var i=this.doPublic(b);var e=i.toString(16).replace(/^1f+00/,"");var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(g.length==0){return false}var d=g[0];var h=g[1];var a=function(k){return KJUR.crypto.Util.hashString(k,d)};var c=a(f);return(h==c)}function _rsasign_verifyWithMessageHash(e,a){a=a.replace(_RE_HEXDECONLY,"");a=a.replace(/[ \n]+/g,"");var b=parseBigInt(a,16);if(b.bitLength()>this.n.bitLength()){return 0}var h=this.doPublic(b);var g=h.toString(16).replace(/^1f+00/,"");var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(g);if(c.length==0){return false}var d=c[0];var f=c[1];return(f==e)}function _rsasign_verifyStringPSS(c,b,a,f){var e=function(g){return KJUR.crypto.Util.hashHex(g,a)};var d=e(rstrtohex(c));if(f===undefined){f=-1}return this.verifyWithMessageHashPSS(d,b,a,f)}function _rsasign_verifyWithMessageHashPSS(f,s,l,c){var k=new BigInteger(s,16);if(k.bitLength()>this.n.bitLength()){return false}var r=function(i){return KJUR.crypto.Util.hashHex(i,l)};var j=hextorstr(f);var h=j.length;var g=this.n.bitLength()-1;var m=Math.ceil(g/8);var q;if(c===-1||c===undefined){c=h}else{if(c===-2){c=m-h-2}else{if(c<-2){throw"invalid salt length"}}}if(m<(h+c+2)){throw"data too long"}var a=this.doPublic(k).toByteArray();for(q=0;q>(8*m-g))&255;if((d.charCodeAt(0)&p)!==0){throw"bits beyond keysize not zero"}var n=pss_mgf1_str(e,d.length,r);var o=[];for(q=0;q 2 | 3 | 4 | Assinatura digital de um arquivo 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 72 | 75 | 76 | 77 |

Assinatura digital de um arquivo

78 | 79 |
80 | 81 | 82 | 83 | 84 | 138 | 139 | 143 | 144 | 145 | 146 | 156 | 157 | 158 | 161 | 164 | 165 | 166 | 170 | 172 | 197 | 198 | 199 |
AssinarVerificar
85 | Chave privada PEM RSA
86 |
103 | 104 | 105 |
106 |
107 | 108 |
109 |
110 |

Arquivo

111 | 112 |
113 | 114 | 137 |
140 | Resultado da verificação 141 |
Please fill values below and push "Verify this sigunature" button.
142 |
147 | 154 |
155 |
159 |
160 |
162 |
163 |
167 | Assinatura do arquivo gerada
168 | 169 |
171 | 173 | 174 | Verificando a assinatura
175 |
177 | 178 | Arquivo a ser verificado.
179 |
180 | 181 | Certificado de chave pública.
182 |
196 |
200 |
201 | 202 | 203 | -------------------------------------------------------------------------------- /jsrsasign/sample-rsasign.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phelipealves/assinaturadigitaljavascript/40cf3b05ff14d0a7316a9ec2f651c0f4266429e6/jsrsasign/sample-rsasign.png -------------------------------------------------------------------------------- /jsrsasign/test/qunit-do-asn1-newobj.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | QUnit for ASN1 Encoder Class 'asn1.js' ASN1Util.newObject 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 176 | 177 | 178 | 179 |
180 |
test markup
181 | 182 | 183 | -------------------------------------------------------------------------------- /jsrsasign/test/qunit-do-base64x.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | QUnit for 'base64x.js' 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 32 | 33 | 34 | 35 |
36 |
test markup
37 | 38 | 39 | -------------------------------------------------------------------------------- /jsrsasign/test/qunit-do-crypto-ecdsa.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | QUnit for Cryptographic Provider Class 'crypto.js' for ECDSA test 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 94 | 95 | 96 | 97 |
98 |
test markup
99 | 100 |

101 | ECC related QUnit test pages: 102 | crypto.js | 103 | crypto.js Signature class for ECDSA | 104 | ecdsa-modified.js | 105 | ecparam.js | 106 |

107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /jsrsasign/test/qunit-do-crypto-mac.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | QUnit for Cryptographic Provider Class 'crypto.js' HMAC test 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 131 | 132 | 133 | 134 |
135 |
test markup
136 | 137 |

138 | crypto.js | 139 |

140 | 141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /jsrsasign/test/qunit-do-crypto-sjcl.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | QUnit for 'crypto.js' with sjcl 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 45 | 46 | 47 | 48 |
49 |
test markup
50 | 51 | 52 | -------------------------------------------------------------------------------- /jsrsasign/test/qunit-do-ecdsamod-s.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | QUnit 'ecdsamod.js' static method test 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 43 | 44 | 45 | 46 |
47 |
test markup
48 | 49 | NOTE: 50 |

51 | Currently this library works for only secp256r1, secp256k1 and secp384r1 EC curves 52 | besides some other curves are pre-defined. 53 |

54 | 55 |

56 | ECC related QUnit test pages: 57 | crypto.js | 58 | crypto.js Signature class for ECDSA | 59 | ecdsa-modified.js | 60 | ecparam.js | 61 |

62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /jsrsasign/test/qunit-do-ecparam.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | QUnit for 'ecparam-1.0.js' 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 44 | 45 | 46 | 47 |
48 |
test markup
49 | 50 |

51 | ECC related QUnit test pages: 52 | crypto.js | 53 | crypto.js Signature class for ECDSA | 54 | ecdsa-modified.js | 55 | ecparam.js | 56 |

57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /jsrsasign/test/qunit-do-keyutil-csr.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | QUnit for CSR in 'keyutil.js' 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 74 | 75 | 76 | 77 |
78 |
test markup
79 | QUnit for 80 | keyutil | 81 | keyutil-eprv | 82 | keyutil-pub | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /jsrsasign/test/qunit-do-keyutil-des.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | QUnit for KEYUTIL DES-CBC PKCS5 private key 'keyutil.js' 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 83 | 84 | 85 | 86 |
87 |
test markup
88 | QUnit for 89 | keyutil | 90 | keyutil-eprv | 91 | keyutil-pub | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /jsrsasign/test/qunit-do-keyutil-gen.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | QUnit for KEYUTIL keypair generator 'keyutil.js' 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 104 | 105 | 106 | 107 |
108 |
test markup
109 | QUnit for 110 | keyutil | 111 | keyutil-eprv | 112 | keyutil-pub | 113 | keyutil-gen | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /jsrsasign/test/qunit-do-keyutil-pub.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | QUnit for PKCS5 RSA key reader 'keyutil.js' for RSA public key 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 111 | 112 | 113 | 114 |
115 |
test markup
116 | QUnit for 117 | keyutil | 118 | keyutil-eprv | 119 | keyutil-pub | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /jsrsasign/test/qunit-do-pkcs5-pub.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | QUnit for PKCS5 RSA key reader 'pkcs5pkey.js' for RSA public key 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 111 | 112 | 113 | 114 |
115 |
test markup
116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /jsrsasign/test/qunit-do-x509-key.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | QUnit for X.509 Certificate 'x509.js' 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 83 | 84 | 85 | 86 |
87 |
test markup
88 | 89 |

© 2010 Kenji Urushima

90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /jsrsasign/test/qunit.css: -------------------------------------------------------------------------------- 1 | /** 2 | * QUnit v1.12.0 - A JavaScript Unit Testing Framework 3 | * 4 | * http://qunitjs.com 5 | * 6 | * Copyright 2012 jQuery Foundation and other contributors 7 | * Released under the MIT license. 8 | * http://jquery.org/license 9 | */ 10 | 11 | /** Font Family and Sizes */ 12 | 13 | #qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult { 14 | font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif; 15 | } 16 | 17 | #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; } 18 | #qunit-tests { font-size: smaller; } 19 | 20 | 21 | /** Resets */ 22 | 23 | #qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter { 24 | margin: 0; 25 | padding: 0; 26 | } 27 | 28 | 29 | /** Header */ 30 | 31 | #qunit-header { 32 | padding: 0.5em 0 0.5em 1em; 33 | 34 | color: #8699a4; 35 | background-color: #0d3349; 36 | 37 | font-size: 1.5em; 38 | line-height: 1em; 39 | font-weight: normal; 40 | 41 | border-radius: 5px 5px 0 0; 42 | -moz-border-radius: 5px 5px 0 0; 43 | -webkit-border-top-right-radius: 5px; 44 | -webkit-border-top-left-radius: 5px; 45 | } 46 | 47 | #qunit-header a { 48 | text-decoration: none; 49 | color: #c2ccd1; 50 | } 51 | 52 | #qunit-header a:hover, 53 | #qunit-header a:focus { 54 | color: #fff; 55 | } 56 | 57 | #qunit-testrunner-toolbar label { 58 | display: inline-block; 59 | padding: 0 .5em 0 .1em; 60 | } 61 | 62 | #qunit-banner { 63 | height: 5px; 64 | } 65 | 66 | #qunit-testrunner-toolbar { 67 | padding: 0.5em 0 0.5em 2em; 68 | color: #5E740B; 69 | background-color: #eee; 70 | overflow: hidden; 71 | } 72 | 73 | #qunit-userAgent { 74 | padding: 0.5em 0 0.5em 2.5em; 75 | background-color: #2b81af; 76 | color: #fff; 77 | text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px; 78 | } 79 | 80 | #qunit-modulefilter-container { 81 | float: right; 82 | } 83 | 84 | /** Tests: Pass/Fail */ 85 | 86 | #qunit-tests { 87 | list-style-position: inside; 88 | } 89 | 90 | #qunit-tests li { 91 | padding: 0.4em 0.5em 0.4em 2.5em; 92 | border-bottom: 1px solid #fff; 93 | list-style-position: inside; 94 | } 95 | 96 | #qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running { 97 | display: none; 98 | } 99 | 100 | #qunit-tests li strong { 101 | cursor: pointer; 102 | } 103 | 104 | #qunit-tests li a { 105 | padding: 0.5em; 106 | color: #c2ccd1; 107 | text-decoration: none; 108 | } 109 | #qunit-tests li a:hover, 110 | #qunit-tests li a:focus { 111 | color: #000; 112 | } 113 | 114 | #qunit-tests li .runtime { 115 | float: right; 116 | font-size: smaller; 117 | } 118 | 119 | .qunit-assert-list { 120 | margin-top: 0.5em; 121 | padding: 0.5em; 122 | 123 | background-color: #fff; 124 | 125 | border-radius: 5px; 126 | -moz-border-radius: 5px; 127 | -webkit-border-radius: 5px; 128 | } 129 | 130 | .qunit-collapsed { 131 | display: none; 132 | } 133 | 134 | #qunit-tests table { 135 | border-collapse: collapse; 136 | margin-top: .2em; 137 | } 138 | 139 | #qunit-tests th { 140 | text-align: right; 141 | vertical-align: top; 142 | padding: 0 .5em 0 0; 143 | } 144 | 145 | #qunit-tests td { 146 | vertical-align: top; 147 | } 148 | 149 | #qunit-tests pre { 150 | margin: 0; 151 | white-space: pre-wrap; 152 | word-wrap: break-word; 153 | } 154 | 155 | #qunit-tests del { 156 | background-color: #e0f2be; 157 | color: #374e0c; 158 | text-decoration: none; 159 | } 160 | 161 | #qunit-tests ins { 162 | background-color: #ffcaca; 163 | color: #500; 164 | text-decoration: none; 165 | } 166 | 167 | /*** Test Counts */ 168 | 169 | #qunit-tests b.counts { color: black; } 170 | #qunit-tests b.passed { color: #5E740B; } 171 | #qunit-tests b.failed { color: #710909; } 172 | 173 | #qunit-tests li li { 174 | padding: 5px; 175 | background-color: #fff; 176 | border-bottom: none; 177 | list-style-position: inside; 178 | } 179 | 180 | /*** Passing Styles */ 181 | 182 | #qunit-tests li li.pass { 183 | color: #3c510c; 184 | background-color: #fff; 185 | border-left: 10px solid #C6E746; 186 | } 187 | 188 | #qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; } 189 | #qunit-tests .pass .test-name { color: #366097; } 190 | 191 | #qunit-tests .pass .test-actual, 192 | #qunit-tests .pass .test-expected { color: #999999; } 193 | 194 | #qunit-banner.qunit-pass { background-color: #C6E746; } 195 | 196 | /*** Failing Styles */ 197 | 198 | #qunit-tests li li.fail { 199 | color: #710909; 200 | background-color: #fff; 201 | border-left: 10px solid #EE5757; 202 | white-space: pre; 203 | } 204 | 205 | #qunit-tests > li:last-child { 206 | border-radius: 0 0 5px 5px; 207 | -moz-border-radius: 0 0 5px 5px; 208 | -webkit-border-bottom-right-radius: 5px; 209 | -webkit-border-bottom-left-radius: 5px; 210 | } 211 | 212 | #qunit-tests .fail { color: #000000; background-color: #EE5757; } 213 | #qunit-tests .fail .test-name, 214 | #qunit-tests .fail .module-name { color: #000000; } 215 | 216 | #qunit-tests .fail .test-actual { color: #EE5757; } 217 | #qunit-tests .fail .test-expected { color: green; } 218 | 219 | #qunit-banner.qunit-fail { background-color: #EE5757; } 220 | 221 | 222 | /** Result */ 223 | 224 | #qunit-testresult { 225 | padding: 0.5em 0.5em 0.5em 2.5em; 226 | 227 | color: #2b81af; 228 | background-color: #D2E0E6; 229 | 230 | border-bottom: 1px solid white; 231 | } 232 | #qunit-testresult .module-name { 233 | font-weight: bold; 234 | } 235 | 236 | /** Fixture */ 237 | 238 | #qunit-fixture { 239 | position: absolute; 240 | top: -10000px; 241 | left: -10000px; 242 | width: 1000px; 243 | height: 1000px; 244 | } 245 | -------------------------------------------------------------------------------- /jsrsasign/tool_certview.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Online Certificate Viewer 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 39 | 40 | 41 | 42 | 43 | 44 |
45 |
46 |

Online Certificate Viewer

47 |

Basic field viewer for PEM formatted X.509 certificate.

48 | TOP | 49 | DOWNLOADS | 50 | TUTORIALS | 51 | API REFERENCE | 52 | DEMOS | 53 |
54 |
55 | 56 | 57 |
58 |
59 | 60 | 61 |
62 |

(Step1) Fill PEM formatted X.509 certificate

63 | 83 | 84 |

(Step2) Press "View" button

85 | 86 | 87 |

Certificate Fields

88 | 89 | 90 | 91 | 95 | 96 | 97 |
SerialNumber:
Issuer:
Validity: 92 | From 93 | To 94 |
Subject:
SHA1 Thumb Print:
98 |
99 | 100 | 101 | 102 |
103 |
104 | 105 | 106 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /jsrsasign/tool_forfact.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | For Checking CSR by factorable.net 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 60 | 61 | 62 | 63 | 64 | 65 |
66 |
67 |

CSR to certificate converter

68 |

for checking weak RSA public key by factorable.net

69 | 70 | TOP | 71 | DOWNLOADS | 72 | TUTORIALS | 73 | API REFERENCE | 74 | DEMOS | 75 |
76 |
77 | 78 | 79 |
80 |
81 | 82 | 83 |
84 |

85 | The factorable.net site provides 86 | key checker to 87 | verify whether weak or compromised key or not. 88 | However this can only check X.509 certificate or SSH public key. 89 | Thus you can't easily check your key before its certificate issuance 90 | by PKCS#10 CSR (certificate signing request) or PKCS#8 PEM public key. 91 |

92 |

93 | This tool can generate a fake certificate by specifying CSR 94 | for checking factorable weak key checker. 95 | Resulting certificate has wrong signature value but it doesn't matter for the checker. 96 |

97 | 98 |

(Step1) Fill PEM formatted PKCS#10 CSR (certificate signing request)

99 | 114 | 115 | 116 | 117 |

(Step2) Press "Convert" button

118 | 119 | 120 | 121 |

Fake Certificate for factorable.net key checker

122 | 123 | 124 |
125 | 126 | Copy this certificate, paste it on the bottom text field of 127 | key checker 128 | then click "Check" button. 129 | You can see the weak key checking result for the CSR and public key pair. 130 | 131 |
132 | 133 | 134 | 135 |
136 |
137 | 138 | 139 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /jsrsasign/tool_pkcs5view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Online Encrypted PKCS#5 PEM RSA Private Key Viewer 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 50 | 51 | 52 | 53 | 54 | 55 |
56 |
57 |

Online Encrypted PKCS#5 PEM RSA Private Key Viewer

58 |

decrypt and see RSA private key fields.

59 | TOP | 60 | DOWNLOADS | 61 | TUTORIALS | 62 | API REFERENCE | 63 | DEMOS | 64 |
65 |
66 | 67 | 68 |
69 |
70 | 71 | 72 |
73 |

(Step1) Fill Encrypted PEM formatted RSA private key

74 | 86 | 87 |

(Step2) Fill passcode to decrypt private key

88 |
89 | NOTE: Passcode for above default RSA private key is 'hogehoge'. 90 | 91 |

(Step3) Press "Decrypt it" button

92 | 93 | 94 |

RSA Private Key

95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 |
modulus(n):
public exponent(e):
private exponent(d):
prime1(p):
prime2(q):
prime1 exponent(dp):
prime2 exponent(dq):
cofficient(co):
105 |
106 | 107 | 108 | 109 |
110 |
111 | 112 | 113 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /jsrsasign/x509-1.1.min.js: -------------------------------------------------------------------------------- 1 | /*! x509-1.1.2.js (c) 2012 Kenji Urushima | kjur.github.com/jsrsasign/license 2 | */ 3 | function X509(){this.subjectPublicKeyRSA=null;this.subjectPublicKeyRSA_hN=null;this.subjectPublicKeyRSA_hE=null;this.hex=null;this.getSerialNumberHex=function(){return ASN1HEX.getDecendantHexVByNthList(this.hex,0,[0,1])};this.getIssuerHex=function(){return ASN1HEX.getDecendantHexTLVByNthList(this.hex,0,[0,3])};this.getIssuerString=function(){return X509.hex2dn(ASN1HEX.getDecendantHexTLVByNthList(this.hex,0,[0,3]))};this.getSubjectHex=function(){return ASN1HEX.getDecendantHexTLVByNthList(this.hex,0,[0,5])};this.getSubjectString=function(){return X509.hex2dn(ASN1HEX.getDecendantHexTLVByNthList(this.hex,0,[0,5]))};this.getNotBefore=function(){var a=ASN1HEX.getDecendantHexVByNthList(this.hex,0,[0,4,0]);a=a.replace(/(..)/g,"%$1");a=decodeURIComponent(a);return a};this.getNotAfter=function(){var a=ASN1HEX.getDecendantHexVByNthList(this.hex,0,[0,4,1]);a=a.replace(/(..)/g,"%$1");a=decodeURIComponent(a);return a};this.readCertPEM=function(c){var e=X509.pemToHex(c);var b=X509.getPublicKeyHexArrayFromCertHex(e);var d=new RSAKey();d.setPublic(b[0],b[1]);this.subjectPublicKeyRSA=d;this.subjectPublicKeyRSA_hN=b[0];this.subjectPublicKeyRSA_hE=b[1];this.hex=e};this.readCertPEMWithoutRSAInit=function(c){var d=X509.pemToHex(c);var b=X509.getPublicKeyHexArrayFromCertHex(d);this.subjectPublicKeyRSA.setPublic(b[0],b[1]);this.subjectPublicKeyRSA_hN=b[0];this.subjectPublicKeyRSA_hE=b[1];this.hex=d}}X509.pemToBase64=function(a){var b=a;b=b.replace("-----BEGIN CERTIFICATE-----","");b=b.replace("-----END CERTIFICATE-----","");b=b.replace(/[ \n]+/g,"");return b};X509.pemToHex=function(a){var c=X509.pemToBase64(a);var b=b64tohex(c);return b};X509.getSubjectPublicKeyPosFromCertHex=function(f){var e=X509.getSubjectPublicKeyInfoPosFromCertHex(f);if(e==-1){return -1}var b=ASN1HEX.getPosArrayOfChildren_AtObj(f,e);if(b.length!=2){return -1}var d=b[1];if(f.substring(d,d+2)!="03"){return -1}var c=ASN1HEX.getStartPosOfV_AtObj(f,d);if(f.substring(c,c+2)!="00"){return -1}return c+2};X509.getSubjectPublicKeyInfoPosFromCertHex=function(d){var c=ASN1HEX.getStartPosOfV_AtObj(d,0);var b=ASN1HEX.getPosArrayOfChildren_AtObj(d,c);if(b.length<1){return -1}if(d.substring(b[0],b[0]+10)=="a003020102"){if(b.length<6){return -1}return b[6]}else{if(b.length<5){return -1}return b[5]}};X509.getPublicKeyHexArrayFromCertHex=function(f){var e=X509.getSubjectPublicKeyPosFromCertHex(f);var b=ASN1HEX.getPosArrayOfChildren_AtObj(f,e);if(b.length!=2){return[]}var d=ASN1HEX.getHexOfV_AtObj(f,b[0]);var c=ASN1HEX.getHexOfV_AtObj(f,b[1]);if(d!=null&&c!=null){return[d,c]}else{return[]}};X509.getHexTbsCertificateFromCert=function(b){var a=ASN1HEX.getStartPosOfV_AtObj(b,0);return a};X509.getPublicKeyHexArrayFromCertPEM=function(c){var d=X509.pemToHex(c);var b=X509.getPublicKeyHexArrayFromCertHex(d);return b};X509.hex2dn=function(e){var f="";var c=ASN1HEX.getPosArrayOfChildren_AtObj(e,0);for(var d=0;d