SlideShare une entreprise Scribd logo
1  sur  41
Télécharger pour lire hors ligne
introduction to
jsrsasign
pure JavaScript cryptographic library
slide r1.0 (2016 Sep 3 for jsrsasign 5.0.15)
press ← ↑ → ↓ key or right bottom buttons to move slides
https://kjur.github.io/jsrsasign
@kjur / Kenji Urushima
Table of Contents
Overview
How to use or install
RSA/DSA/ECDSA public key cryptography
Cryptographic Hash (SHA1/SHA2/MD5/RIPEMD160)
Message Authentication Code (HmacSHA1/SHA2/MD5)
short ASN.1 introduction
ASN1HEX: simple ASN.1 parser
X509: simple X.509 certi cate parser
generate and encode ASN.1
JSON Web Key/Signature/Token (JWK/JWS/JWT)
Tools, Demos, Tutorials and API Docs
Overview
The "jsrsasign" ( ) is a open source
free cryptograhic library implemented by pure JavaScript. It supports a
lot of features such as following:
strong RSA/DSA/ECDSA key utility
RSA/DSA/ECDSA digital signature
message authentication code(MAC)
hash (MD5,RIPEMD,SHA1,SHA2)
simple ASN.1 parser
ASN.1 object generator
X.509 certi cate and CRL
PKCS#1/5/8 private/public key
PKCS#10/CSR
CMS SignedData
RFC 3161 TimeStamp
CAdES long term signature
JWS (JSON Web Signatures)
JWT (JSON Web Token)
JWK (JSON Web Key)
string utility
https://kjur.github.io/jsrsasign/
Overview (cont'd)
well-documented
"jsrsasign" has rich and so that you can learn
easily.
many samples and tools
"jsrsasign" provides many samples and tools.
easy installation
"jsrsasign" can be easily installed by "git clone", bower and npm.
There is no dependency to other package or module.
works on most of browsers and Node.js
"jsrsasign" doesn't require any special feature of JavaScript on the
browser such like W3C Web Crypto or Promise. This works on most
of browsers and Node.js as if old one.
MIT license
"jsrsasign" is licensed under "MIT License" which is short and
permissive for developers convenience.
API reference tutorial
jsrsasign architecture
How to use or install
For bower:
For Node.js:
O course, you can use git:
Or to use it in your web page, add following in your HTML:
% bower install jsrsasign
% npm install -g jsrsasign (for global installation)
% git clone https://github.com/kjur/jsrsasign.git
<script src="https://kjur.github.io/jsrsasign/jsrsasign-
latest-all-min.js"></script>
RSA/DSA/ECDSA public key
cryptography
KEYUTIL class: Features
supports RSA/DSA/ECC algorithm
generateKeypair() for RSA/ECC
getKey(): key loader
PKCS#1/5 plain/encryptped private/public PEM/HEX key
PKCS#8 plain/encryptped private/public PEM/HEX key
X.509 PEM certi cate
public/private RFC 7517 JSON Web Key (JWK)
getPEM() to get plain/encrypted private/public PKCS#1/5/8 PEM
getJWKFromKey() to get RFC 7517 JSON Web Key (JWK)
KEYUTIL.generateKeypair()
generateKeypair method can be used to generate RSA/ECC key pair.
// RSA
keypair = KEYUTIL.generateKeypair("RSA", 2048);
// ECC
keypair = KEYUTIL.generateKeypair("EC", "secp256r1");
//
// private key object: keypair.prvKeyObj
// public key object: keypair.pubKeyObj
KEYUTIL.getKey()
getKey method can load a lot of format of public and private key such
as PKCS#1/5/8 or JWK very easily.
// PKCS#8 public key
pub = KEYUTIL.getKey("-----BEGIN PUBLIC KEY...");
// public key from X.509 certi cate
pub = KEYUTIL.getKey("-----BEGIN CERTIFICATE...");
// PKCS#8 encrypted private with password
prv = KEYUTIL.getKey("-----BEGIN ENCRYPTED PRIVATE KEY...", "pass");
sign data
sign a data with your private key using Signature object as like Java JCE.
// load private key
prv = KEYUTIL.getKey("-----BEGIN ENCRYPTED PRIVATE KEY...", "pass");
// generate Signature object
sig = new KJUR.crypto.Signature({"alg": "SHA256withRSA"});
// set private key for sign
sig.init(prv);
// update data
sig.updateString("aaa");
// calclate signature
sigHex = sig.sign();
verify signature
sign a data with your private key using Signature object as like Java JCE.
// load public key
pub = KEYUTIL.getKey("-----BEGIN CERTIFICATE...");
// generate Signature object
sig = new KJUR.crypto.Signature({"alg": "SHA256withRSA"});
// set private key for sign
sig.init(pub);
// update data
sig.updateString("aaa");
// verify signature
isValid = sig.verify(sigValueHex);
Cryptographic Hash
SHA1/SHA2/MD5/RIPEMD160
calculate hash by
MessageDigest class
calculate hash using MessageDigest class just like Java JCE
// generate MessageDigest object for SHA384
md = new KJUR.crypto.MessageDigest({alg: "sha384"});
// append data for hash
md.updateString("aaa");
// calculate hash nally
mdHex = md.digest();
// or use Util class in short. These three will get the same result.
mdHex = KJUR.crypto.Util.sha384("aaa");
mdHex = KJUR.crypto.Util.hashString("aaa","sha384");
mdHex = KJUR.crypto.Util.hashHex("616161","sha384");
Message Authentication Code
(HmacSHA1/SHA2/MD5)
calculate Mac by Mac class
calculate message authentication code by Mac class just like Java JCE
// generate Mac class
mac = new KJUR.crypto.Mac({alg: "HmacSHA256", pass: "pass"});
// append data for Mac
mac.updateString('aaa');
// get Mac value
macHex = md.doFinal();
pass parameter supports some value formats like this:
hexadecimal {hex: "616161"}
UTF-8 {utf8: "東京"}
Base64 {b64: "Mi02/+...a=="}
Base64URL {b64u: "Mi02_-...a"}
short ASN.1 introduction
short ASN.1 introduction
ASN.1 is a binary encording of structured data consists of a data type
tag(T), byte length(L) and value(V).
ASN.1 encoding is used in network protocol or format such like X.509
certi cate, private/public key formats, S/MIME data, digital time stamp,
Radius.
FEATURE1: variable length data exceeds int or long.
FEATURE2: structured data is also available.
short ASN.1 introduction
(cont'd)
Structured data can be represented by SEQUENCE or SET.
ASN1HEX
simple ASN.1 parser for hexadecimal string
ASN1HEX basic methods
ASN1HEX methods can be used for getting tag, length or value of ASN.1
object of hexadecimal string at speci ed position.
ASN1HEX basic methods
(cont'd)
get a list of indexes of child elements.
ASN1HEX for decendant
element
To refer a decendant element of nested structured ASN.1, use "nthList"
which represent indexes for each nested layer. This is very useful to
specify a deep nested element such like subject name of X.509
certi cate.
getDecendantHexTLVByNthList(s,0,[0,0]) → "020104"
getDecendantHexLByNthList(s,0,[0,0]) → "01"
getDecendantHexVByNthList(s,0,[0,0]) → "04"
getDecendantIndexByNthList(s,0,[0,0]) → 8
←
X509
simple X.509 certificate parser as ASN.1
X509 class
Basic fields and extensions can be get by X509 class.
x = new X509();
x.readCertPEM(sCertPEM);
hex = X.509.pemToHex(sCertPEM);
// get subject
subject = x.getSubjectString(); // return like "/C=US/O=OTEST"
// get subjectAltName
san = X.509.getExtSubjectAltName(hex);
// return like ["example.com", "example.org"]
There are a lot of methods to get elds and extensions.
Please see in detail.manual
generate and encode ASN.1
generate and encode ASN.1 (cont'd)
Classes for ASN.1 primitives and structured types, as well as X.509
certi cate, CRL, CSR, CMS signed data, digital time stamp and CAdES are
de ned in jsrsasign.
i1 = new KJUR.asn1.DERInteger({int: 234});
s1 = new KJUR.asn1.DERUTF8String({str: 'Tokyo'}});
seq = new KJUR.asn1.DERSequence({array: [i1, s1]});
hex = seq.getEncodedHex();
Please see in detail.
It's very similar to BoucyCastle or IAIK Java ASN.1 classes.
However, there is much more easy way...
manual
generate and encode ASN.1 using
newObject
It's very easy to generate complicated ASN.1 object by
ASN1Util.newObject
var hex = new KJUR.asn1.ASN1Util.newObject(
  {seq: [              // SEQUENCE
     {int: 234},          // INTEGER
     {utf8str: 'Tokyo'}      // UTF8String
     ]}
).getEncodedHex();
get PEM of X.509 certificate by
X509Util.newCertPEM
It's very easy to generate PEM of X.509 certi cate by
.
pem = new KJUR.asn1.x509.X509Util.newCertPEM({
  serial: {int: 4},
  sigalg: {name: 'SHA256withECDSA', paramempty: true},
  issuer: {str: '/C=US/O=CA1'},
  notbefore: {str: '130504235959Z'}, notafter: {str: '140504235959Z'},
  subject: {str: '/C=US/O=T1'},
  sbjpubkey: "-----BEGIN PUBLIC KEY...",
  ext: [
    {basicConstraints: {cA: true, critical: true}},
    {keyUsage: {bin: '11'}},
  ],
  cakey: ["-----BEGIN PRIVATE KEY...", "pass"]
});
X509Util.newCertPEM
get PEM of PKCS#10/CSRT by
CSRUtil.newCSRPEM
It's very easy to generate PEM of CSR(certi cate signing request) by
.
kp = KEYUTIL.generateKeypair("RSA", 2048);
pem = new KJUR.asn1.csr.CSRUtil.newCSRPEM({
  subject: {str: '/C=US/O=Test/CN=example.com'},
  sbjpubkey: kp.pubKeyObj,
  sigalg: "SHA256withRSA",
  sbjprvkey: kp.prvKeyObj
});
CSRUtil.newCSRPEM
JWK
JWS
JWT
JWK (JSON Web Key)
jsrsasign can load and export RFC 7517 JSON Web Key (JWK).
// load JWK
jwkPub = {kty: "EC", crv: "P-256", x: "f830J3..." ...};
keyObj = KEYUTIL.getKey(jwkPub);
// export to JWK
kp = KEYUTIL.generateKeypair("RSA", 2048);
jwkPrv = KEYUTIL.getJWKFromKey(kp.prvKeyObj);
jwkPub = KEYUTIL.getJWKFromKey(kp.pubKeyObj);
JWS (JSON Web Signatures)
jsrsasign can sign and verify RFC 7515 JSON Web Signatures (JWS).
// sign JWS
header = {alg: "HS256"};
payload = {fruit: "orange"};
jws = KJUR.jws.JWS.sign("HS256", header, payload, {utf8: "secret"});
// eyJhbGciOiJIUzI1NiJ9.eyJmcnVpdCI6Im9yYW5nZSJ9.
// qbIF5WMbXYMFMh_UXjL2CGts5KPVU7yF7AbOdoyoPZI
// verify JWS
isValid = KJUR.jws.JWS.verify(jws, {utf8: "secret"}, ["HS256"]);
This result can also be veri ed at .jwt.io
JWS signature generation flow
JWT (JSON Web Token)
jsrsasign can sign and verify RFC 7519 JSON Web Token (JWT).
// sign JWT
header = {alg: "HS256", typ: "JWT"};
payload = {sub: "123456789", name: "John Doe", admin: true};
jwt = KJUR.jws.JWS.sign("HS256", header, payload, {utf8: "secret"});
// eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY
// 3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95
// OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ
// verify JWT
isValid = KJUR.jws.JWS.verifyJWT(jwt, {utf8: "secret"}, {
 alg: ["HS256"], sub: ["John Doe"]
});
This result can also be veri ed at .jwt.io
jsrsasign at jwt.io
site have kindly listed jsrsasign. jwt.io provides JWT validator
which uses .
jwt.io
old version of jsrsasign 4.1.5
Tools, Demos, Tutorials and API
Docs
Tools and demos
jsrsasign provides a lot of tools which use
jsrsasign as example.
Please see the as for onliene
tools.
Also see as for Node tools.
As for demonstrations, please see
.
this list
list
this list
Tutorials
jsrsasign provides to
make it easy to learn jsrsasign programming.
tutorial documents
API Reference
jsrsasign provides detailed
document. API reference also has examples.
API Reference
Thank you for your attention.

Contenu connexe

Tendances

Railway Oriented Programming
Railway Oriented ProgrammingRailway Oriented Programming
Railway Oriented ProgrammingScott Wlaschin
 
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...Mario Heiderich
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlinintelliyole
 
Kotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime PerformanceKotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime Performanceintelliyole
 
JavaScript - Chapter 7 - Advanced Functions
 JavaScript - Chapter 7 - Advanced Functions JavaScript - Chapter 7 - Advanced Functions
JavaScript - Chapter 7 - Advanced FunctionsWebStackAcademy
 
Java EE no ambiente corporativo: primeiros passos WebLogic 12c
Java EE no ambiente corporativo: primeiros passos WebLogic 12cJava EE no ambiente corporativo: primeiros passos WebLogic 12c
Java EE no ambiente corporativo: primeiros passos WebLogic 12cBruno Borges
 
Netty Notes Part 3 - Channel Pipeline and EventLoops
Netty Notes Part 3 - Channel Pipeline and EventLoopsNetty Notes Part 3 - Channel Pipeline and EventLoops
Netty Notes Part 3 - Channel Pipeline and EventLoopsRick Hightower
 
Jetpack Compose a nova forma de implementar UI no Android
Jetpack Compose a nova forma de implementar UI no AndroidJetpack Compose a nova forma de implementar UI no Android
Jetpack Compose a nova forma de implementar UI no AndroidNelson Glauber Leal
 
Domain Driven Design with the F# type System -- NDC London 2013
Domain Driven Design with the F# type System -- NDC London 2013Domain Driven Design with the F# type System -- NDC London 2013
Domain Driven Design with the F# type System -- NDC London 2013Scott Wlaschin
 
서버 아키텍처 이해를 위한 프로세스와 쓰레드
서버 아키텍처 이해를 위한 프로세스와 쓰레드서버 아키텍처 이해를 위한 프로세스와 쓰레드
서버 아키텍처 이해를 위한 프로세스와 쓰레드KwangSeob Jeong
 
Basic Javascript
Basic JavascriptBasic Javascript
Basic JavascriptBunlong Van
 
SSL Communication and Mutual Authentication
SSL Communication and Mutual AuthenticationSSL Communication and Mutual Authentication
SSL Communication and Mutual AuthenticationCleo
 
HTML by Telerik Akademy
HTML by Telerik AkademyHTML by Telerik Akademy
HTML by Telerik AkademyOgnyan Penkov
 
Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1Philip Schwarz
 
[KGC 2011]Boost 라이브러리와 C++11
[KGC 2011]Boost 라이브러리와 C++11[KGC 2011]Boost 라이브러리와 C++11
[KGC 2011]Boost 라이브러리와 C++11흥배 최
 
[Spring Camp 2018] 11번가 Spring Cloud 기반 MSA로의 전환 : 지난 1년간의 이야기
[Spring Camp 2018] 11번가 Spring Cloud 기반 MSA로의 전환 : 지난 1년간의 이야기[Spring Camp 2018] 11번가 Spring Cloud 기반 MSA로의 전환 : 지난 1년간의 이야기
[Spring Camp 2018] 11번가 Spring Cloud 기반 MSA로의 전환 : 지난 1년간의 이야기YongSung Yoon
 

Tendances (20)

Railway Oriented Programming
Railway Oriented ProgrammingRailway Oriented Programming
Railway Oriented Programming
 
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlin
 
Demystifying OAuth 2.0
Demystifying OAuth 2.0Demystifying OAuth 2.0
Demystifying OAuth 2.0
 
Kotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime PerformanceKotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime Performance
 
JavaScript - Chapter 7 - Advanced Functions
 JavaScript - Chapter 7 - Advanced Functions JavaScript - Chapter 7 - Advanced Functions
JavaScript - Chapter 7 - Advanced Functions
 
Java EE no ambiente corporativo: primeiros passos WebLogic 12c
Java EE no ambiente corporativo: primeiros passos WebLogic 12cJava EE no ambiente corporativo: primeiros passos WebLogic 12c
Java EE no ambiente corporativo: primeiros passos WebLogic 12c
 
Netty Notes Part 3 - Channel Pipeline and EventLoops
Netty Notes Part 3 - Channel Pipeline and EventLoopsNetty Notes Part 3 - Channel Pipeline and EventLoops
Netty Notes Part 3 - Channel Pipeline and EventLoops
 
Jetpack Compose a nova forma de implementar UI no Android
Jetpack Compose a nova forma de implementar UI no AndroidJetpack Compose a nova forma de implementar UI no Android
Jetpack Compose a nova forma de implementar UI no Android
 
Domain Driven Design with the F# type System -- NDC London 2013
Domain Driven Design with the F# type System -- NDC London 2013Domain Driven Design with the F# type System -- NDC London 2013
Domain Driven Design with the F# type System -- NDC London 2013
 
Async Programming in C# 5
Async Programming in C# 5Async Programming in C# 5
Async Programming in C# 5
 
서버 아키텍처 이해를 위한 프로세스와 쓰레드
서버 아키텍처 이해를 위한 프로세스와 쓰레드서버 아키텍처 이해를 위한 프로세스와 쓰레드
서버 아키텍처 이해를 위한 프로세스와 쓰레드
 
Basic Javascript
Basic JavascriptBasic Javascript
Basic Javascript
 
Idiomatic kotlin
Idiomatic kotlinIdiomatic kotlin
Idiomatic kotlin
 
SSL Communication and Mutual Authentication
SSL Communication and Mutual AuthenticationSSL Communication and Mutual Authentication
SSL Communication and Mutual Authentication
 
HTML by Telerik Akademy
HTML by Telerik AkademyHTML by Telerik Akademy
HTML by Telerik Akademy
 
Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1
 
[KGC 2011]Boost 라이브러리와 C++11
[KGC 2011]Boost 라이브러리와 C++11[KGC 2011]Boost 라이브러리와 C++11
[KGC 2011]Boost 라이브러리와 C++11
 
[Spring Camp 2018] 11번가 Spring Cloud 기반 MSA로의 전환 : 지난 1년간의 이야기
[Spring Camp 2018] 11번가 Spring Cloud 기반 MSA로의 전환 : 지난 1년간의 이야기[Spring Camp 2018] 11번가 Spring Cloud 기반 MSA로의 전환 : 지난 1년간의 이야기
[Spring Camp 2018] 11번가 Spring Cloud 기반 MSA로의 전환 : 지난 1년간의 이야기
 
Why HATEOAS
Why HATEOASWhy HATEOAS
Why HATEOAS
 

En vedette

ちゃんと理解するForce.com canvas
ちゃんと理解するForce.com canvasちゃんと理解するForce.com canvas
ちゃんと理解するForce.com canvasHiroshi Nakamura
 
エンタープライズソフトウェア開発とOSS
エンタープライズソフトウェア開発とOSSエンタープライズソフトウェア開発とOSS
エンタープライズソフトウェア開発とOSSHiroshi Nakamura
 
第2回Web技術勉強会 webパフォーマンス改善編
第2回Web技術勉強会 webパフォーマンス改善編第2回Web技術勉強会 webパフォーマンス改善編
第2回Web技術勉強会 webパフォーマンス改善編tzm_freedom
 
qpstudy 2015.11.14 一歩先を行くインフラエンジニアに知ってほしいSSL/TLS
qpstudy 2015.11.14 一歩先を行くインフラエンジニアに知ってほしいSSL/TLSqpstudy 2015.11.14 一歩先を行くインフラエンジニアに知ってほしいSSL/TLS
qpstudy 2015.11.14 一歩先を行くインフラエンジニアに知ってほしいSSL/TLSKenji Urushima
 
私はここでつまづいた! Oracle database 11g から 12cへのアップグレードと Oracle Database 12c の新機能@201...
私はここでつまづいた! Oracle database 11g から 12cへのアップグレードと Oracle Database 12c の新機能@201...私はここでつまづいた! Oracle database 11g から 12cへのアップグレードと Oracle Database 12c の新機能@201...
私はここでつまづいた! Oracle database 11g から 12cへのアップグレードと Oracle Database 12c の新機能@201...yoshimotot
 
第3回web技術勉強会 暗号技術編その1
第3回web技術勉強会 暗号技術編その1第3回web技術勉強会 暗号技術編その1
第3回web技術勉強会 暗号技術編その1tzm_freedom
 
いろいろなSSL/TLS設定ガイドライン (JNSA電子署名WG 実世界の暗号・認証技術勉強会資料)
いろいろなSSL/TLS設定ガイドライン (JNSA電子署名WG 実世界の暗号・認証技術勉強会資料)いろいろなSSL/TLS設定ガイドライン (JNSA電子署名WG 実世界の暗号・認証技術勉強会資料)
いろいろなSSL/TLS設定ガイドライン (JNSA電子署名WG 実世界の暗号・認証技術勉強会資料)Kenji Urushima
 
セキュリティ勉強会 暗号技術入門 1章
セキュリティ勉強会 暗号技術入門 1章セキュリティ勉強会 暗号技術入門 1章
セキュリティ勉強会 暗号技術入門 1章Naoko Suzuki
 
Analytics CloudとEmbulkを使った社会的データの分析
Analytics CloudとEmbulkを使った社会的データの分析Analytics CloudとEmbulkを使った社会的データの分析
Analytics CloudとEmbulkを使った社会的データの分析tzm_freedom
 
第4回web技術勉強会 暗号技術編その2
第4回web技術勉強会 暗号技術編その2第4回web技術勉強会 暗号技術編その2
第4回web技術勉強会 暗号技術編その2tzm_freedom
 
第5回web技術勉強会 暗号技術編その3
第5回web技術勉強会 暗号技術編その3第5回web技術勉強会 暗号技術編その3
第5回web技術勉強会 暗号技術編その3tzm_freedom
 
Certificate TransparencyによるSSLサーバー証明書公開監査情報とその課題の議論
Certificate TransparencyによるSSLサーバー証明書公開監査情報とその課題の議論Certificate TransparencyによるSSLサーバー証明書公開監査情報とその課題の議論
Certificate TransparencyによるSSLサーバー証明書公開監査情報とその課題の議論Kenji Urushima
 

En vedette (12)

ちゃんと理解するForce.com canvas
ちゃんと理解するForce.com canvasちゃんと理解するForce.com canvas
ちゃんと理解するForce.com canvas
 
エンタープライズソフトウェア開発とOSS
エンタープライズソフトウェア開発とOSSエンタープライズソフトウェア開発とOSS
エンタープライズソフトウェア開発とOSS
 
第2回Web技術勉強会 webパフォーマンス改善編
第2回Web技術勉強会 webパフォーマンス改善編第2回Web技術勉強会 webパフォーマンス改善編
第2回Web技術勉強会 webパフォーマンス改善編
 
qpstudy 2015.11.14 一歩先を行くインフラエンジニアに知ってほしいSSL/TLS
qpstudy 2015.11.14 一歩先を行くインフラエンジニアに知ってほしいSSL/TLSqpstudy 2015.11.14 一歩先を行くインフラエンジニアに知ってほしいSSL/TLS
qpstudy 2015.11.14 一歩先を行くインフラエンジニアに知ってほしいSSL/TLS
 
私はここでつまづいた! Oracle database 11g から 12cへのアップグレードと Oracle Database 12c の新機能@201...
私はここでつまづいた! Oracle database 11g から 12cへのアップグレードと Oracle Database 12c の新機能@201...私はここでつまづいた! Oracle database 11g から 12cへのアップグレードと Oracle Database 12c の新機能@201...
私はここでつまづいた! Oracle database 11g から 12cへのアップグレードと Oracle Database 12c の新機能@201...
 
第3回web技術勉強会 暗号技術編その1
第3回web技術勉強会 暗号技術編その1第3回web技術勉強会 暗号技術編その1
第3回web技術勉強会 暗号技術編その1
 
いろいろなSSL/TLS設定ガイドライン (JNSA電子署名WG 実世界の暗号・認証技術勉強会資料)
いろいろなSSL/TLS設定ガイドライン (JNSA電子署名WG 実世界の暗号・認証技術勉強会資料)いろいろなSSL/TLS設定ガイドライン (JNSA電子署名WG 実世界の暗号・認証技術勉強会資料)
いろいろなSSL/TLS設定ガイドライン (JNSA電子署名WG 実世界の暗号・認証技術勉強会資料)
 
セキュリティ勉強会 暗号技術入門 1章
セキュリティ勉強会 暗号技術入門 1章セキュリティ勉強会 暗号技術入門 1章
セキュリティ勉強会 暗号技術入門 1章
 
Analytics CloudとEmbulkを使った社会的データの分析
Analytics CloudとEmbulkを使った社会的データの分析Analytics CloudとEmbulkを使った社会的データの分析
Analytics CloudとEmbulkを使った社会的データの分析
 
第4回web技術勉強会 暗号技術編その2
第4回web技術勉強会 暗号技術編その2第4回web技術勉強会 暗号技術編その2
第4回web技術勉強会 暗号技術編その2
 
第5回web技術勉強会 暗号技術編その3
第5回web技術勉強会 暗号技術編その3第5回web技術勉強会 暗号技術編その3
第5回web技術勉強会 暗号技術編その3
 
Certificate TransparencyによるSSLサーバー証明書公開監査情報とその課題の議論
Certificate TransparencyによるSSLサーバー証明書公開監査情報とその課題の議論Certificate TransparencyによるSSLサーバー証明書公開監査情報とその課題の議論
Certificate TransparencyによるSSLサーバー証明書公開監査情報とその課題の議論
 

Similaire à introduction to jsrsasign

OpenSSL Basic Function Call Flow
OpenSSL Basic Function Call FlowOpenSSL Basic Function Call Flow
OpenSSL Basic Function Call FlowWilliam Lee
 
Elasticsearch And Apache Lucene For Apache Spark And MLlib
Elasticsearch And Apache Lucene For Apache Spark And MLlibElasticsearch And Apache Lucene For Apache Spark And MLlib
Elasticsearch And Apache Lucene For Apache Spark And MLlibJen Aman
 
Introduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy CresineIntroduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy CresineMovel
 
Open SSL and MS Crypto API EKON21
Open SSL and MS Crypto API EKON21Open SSL and MS Crypto API EKON21
Open SSL and MS Crypto API EKON21Max Kleiner
 
maxbox starter72 multilanguage coding
maxbox starter72 multilanguage codingmaxbox starter72 multilanguage coding
maxbox starter72 multilanguage codingMax Kleiner
 
DEF CON 23: Stick That In Your (root)Pipe & Smoke It
DEF CON 23: Stick That In Your (root)Pipe & Smoke ItDEF CON 23: Stick That In Your (root)Pipe & Smoke It
DEF CON 23: Stick That In Your (root)Pipe & Smoke ItSynack
 
VisualWorks Security Reloaded - STIC 2012
VisualWorks Security Reloaded - STIC 2012VisualWorks Security Reloaded - STIC 2012
VisualWorks Security Reloaded - STIC 2012Martin Kobetic
 
Adventures in Underland: Is encryption solid as a rock or a handful of dust?
Adventures in Underland: Is encryption solid as a rock or a handful of dust?Adventures in Underland: Is encryption solid as a rock or a handful of dust?
Adventures in Underland: Is encryption solid as a rock or a handful of dust?Paula Januszkiewicz
 
Javascript Object Signing & Encryption
Javascript Object Signing & EncryptionJavascript Object Signing & Encryption
Javascript Object Signing & EncryptionAaron Zauner
 
Spark with Elasticsearch - umd version 2014
Spark with Elasticsearch - umd version 2014Spark with Elasticsearch - umd version 2014
Spark with Elasticsearch - umd version 2014Holden Karau
 
One Click Ownage Ferruh Mavituna (3)
One Click Ownage Ferruh Mavituna (3)One Click Ownage Ferruh Mavituna (3)
One Click Ownage Ferruh Mavituna (3)Ferruh Mavituna
 
Blaise_UK_109_Max Kleiner_image2textAPI.pdf
Blaise_UK_109_Max Kleiner_image2textAPI.pdfBlaise_UK_109_Max Kleiner_image2textAPI.pdf
Blaise_UK_109_Max Kleiner_image2textAPI.pdfbreitschbreitsch
 
12 symmetric key cryptography
12   symmetric key cryptography12   symmetric key cryptography
12 symmetric key cryptographydrewz lin
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express Jeetendra singh
 
Automation with Packer and TerraForm
Automation with Packer and TerraFormAutomation with Packer and TerraForm
Automation with Packer and TerraFormWesley Charles Blake
 

Similaire à introduction to jsrsasign (20)

OpenSSL Basic Function Call Flow
OpenSSL Basic Function Call FlowOpenSSL Basic Function Call Flow
OpenSSL Basic Function Call Flow
 
Elasticsearch And Apache Lucene For Apache Spark And MLlib
Elasticsearch And Apache Lucene For Apache Spark And MLlibElasticsearch And Apache Lucene For Apache Spark And MLlib
Elasticsearch And Apache Lucene For Apache Spark And MLlib
 
Log analysis with elastic stack
Log analysis with elastic stackLog analysis with elastic stack
Log analysis with elastic stack
 
Introduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy CresineIntroduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy Cresine
 
Open SSL and MS Crypto API EKON21
Open SSL and MS Crypto API EKON21Open SSL and MS Crypto API EKON21
Open SSL and MS Crypto API EKON21
 
maxbox starter72 multilanguage coding
maxbox starter72 multilanguage codingmaxbox starter72 multilanguage coding
maxbox starter72 multilanguage coding
 
DEF CON 23: Stick That In Your (root)Pipe & Smoke It
DEF CON 23: Stick That In Your (root)Pipe & Smoke ItDEF CON 23: Stick That In Your (root)Pipe & Smoke It
DEF CON 23: Stick That In Your (root)Pipe & Smoke It
 
VisualWorks Security Reloaded - STIC 2012
VisualWorks Security Reloaded - STIC 2012VisualWorks Security Reloaded - STIC 2012
VisualWorks Security Reloaded - STIC 2012
 
SSL/TLS
SSL/TLSSSL/TLS
SSL/TLS
 
Discovering OpenBSD on AWS
Discovering OpenBSD on AWSDiscovering OpenBSD on AWS
Discovering OpenBSD on AWS
 
Adventures in Underland: Is encryption solid as a rock or a handful of dust?
Adventures in Underland: Is encryption solid as a rock or a handful of dust?Adventures in Underland: Is encryption solid as a rock or a handful of dust?
Adventures in Underland: Is encryption solid as a rock or a handful of dust?
 
Javascript Object Signing & Encryption
Javascript Object Signing & EncryptionJavascript Object Signing & Encryption
Javascript Object Signing & Encryption
 
Spark with Elasticsearch - umd version 2014
Spark with Elasticsearch - umd version 2014Spark with Elasticsearch - umd version 2014
Spark with Elasticsearch - umd version 2014
 
Node intro
Node introNode intro
Node intro
 
ECMAScript 2015
ECMAScript 2015ECMAScript 2015
ECMAScript 2015
 
One Click Ownage Ferruh Mavituna (3)
One Click Ownage Ferruh Mavituna (3)One Click Ownage Ferruh Mavituna (3)
One Click Ownage Ferruh Mavituna (3)
 
Blaise_UK_109_Max Kleiner_image2textAPI.pdf
Blaise_UK_109_Max Kleiner_image2textAPI.pdfBlaise_UK_109_Max Kleiner_image2textAPI.pdf
Blaise_UK_109_Max Kleiner_image2textAPI.pdf
 
12 symmetric key cryptography
12   symmetric key cryptography12   symmetric key cryptography
12 symmetric key cryptography
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express
 
Automation with Packer and TerraForm
Automation with Packer and TerraFormAutomation with Packer and TerraForm
Automation with Packer and TerraForm
 

Dernier

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Dernier (20)

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

introduction to jsrsasign

  • 1. introduction to jsrsasign pure JavaScript cryptographic library slide r1.0 (2016 Sep 3 for jsrsasign 5.0.15) press ← ↑ → ↓ key or right bottom buttons to move slides https://kjur.github.io/jsrsasign @kjur / Kenji Urushima
  • 2. Table of Contents Overview How to use or install RSA/DSA/ECDSA public key cryptography Cryptographic Hash (SHA1/SHA2/MD5/RIPEMD160) Message Authentication Code (HmacSHA1/SHA2/MD5) short ASN.1 introduction ASN1HEX: simple ASN.1 parser X509: simple X.509 certi cate parser generate and encode ASN.1 JSON Web Key/Signature/Token (JWK/JWS/JWT) Tools, Demos, Tutorials and API Docs
  • 3. Overview The "jsrsasign" ( ) is a open source free cryptograhic library implemented by pure JavaScript. It supports a lot of features such as following: strong RSA/DSA/ECDSA key utility RSA/DSA/ECDSA digital signature message authentication code(MAC) hash (MD5,RIPEMD,SHA1,SHA2) simple ASN.1 parser ASN.1 object generator X.509 certi cate and CRL PKCS#1/5/8 private/public key PKCS#10/CSR CMS SignedData RFC 3161 TimeStamp CAdES long term signature JWS (JSON Web Signatures) JWT (JSON Web Token) JWK (JSON Web Key) string utility https://kjur.github.io/jsrsasign/
  • 4. Overview (cont'd) well-documented "jsrsasign" has rich and so that you can learn easily. many samples and tools "jsrsasign" provides many samples and tools. easy installation "jsrsasign" can be easily installed by "git clone", bower and npm. There is no dependency to other package or module. works on most of browsers and Node.js "jsrsasign" doesn't require any special feature of JavaScript on the browser such like W3C Web Crypto or Promise. This works on most of browsers and Node.js as if old one. MIT license "jsrsasign" is licensed under "MIT License" which is short and permissive for developers convenience. API reference tutorial
  • 6. How to use or install For bower: For Node.js: O course, you can use git: Or to use it in your web page, add following in your HTML: % bower install jsrsasign % npm install -g jsrsasign (for global installation) % git clone https://github.com/kjur/jsrsasign.git <script src="https://kjur.github.io/jsrsasign/jsrsasign- latest-all-min.js"></script>
  • 8. KEYUTIL class: Features supports RSA/DSA/ECC algorithm generateKeypair() for RSA/ECC getKey(): key loader PKCS#1/5 plain/encryptped private/public PEM/HEX key PKCS#8 plain/encryptped private/public PEM/HEX key X.509 PEM certi cate public/private RFC 7517 JSON Web Key (JWK) getPEM() to get plain/encrypted private/public PKCS#1/5/8 PEM getJWKFromKey() to get RFC 7517 JSON Web Key (JWK)
  • 9. KEYUTIL.generateKeypair() generateKeypair method can be used to generate RSA/ECC key pair. // RSA keypair = KEYUTIL.generateKeypair("RSA", 2048); // ECC keypair = KEYUTIL.generateKeypair("EC", "secp256r1"); // // private key object: keypair.prvKeyObj // public key object: keypair.pubKeyObj
  • 10. KEYUTIL.getKey() getKey method can load a lot of format of public and private key such as PKCS#1/5/8 or JWK very easily. // PKCS#8 public key pub = KEYUTIL.getKey("-----BEGIN PUBLIC KEY..."); // public key from X.509 certi cate pub = KEYUTIL.getKey("-----BEGIN CERTIFICATE..."); // PKCS#8 encrypted private with password prv = KEYUTIL.getKey("-----BEGIN ENCRYPTED PRIVATE KEY...", "pass");
  • 11. sign data sign a data with your private key using Signature object as like Java JCE. // load private key prv = KEYUTIL.getKey("-----BEGIN ENCRYPTED PRIVATE KEY...", "pass"); // generate Signature object sig = new KJUR.crypto.Signature({"alg": "SHA256withRSA"}); // set private key for sign sig.init(prv); // update data sig.updateString("aaa"); // calclate signature sigHex = sig.sign();
  • 12. verify signature sign a data with your private key using Signature object as like Java JCE. // load public key pub = KEYUTIL.getKey("-----BEGIN CERTIFICATE..."); // generate Signature object sig = new KJUR.crypto.Signature({"alg": "SHA256withRSA"}); // set private key for sign sig.init(pub); // update data sig.updateString("aaa"); // verify signature isValid = sig.verify(sigValueHex);
  • 14. calculate hash by MessageDigest class calculate hash using MessageDigest class just like Java JCE // generate MessageDigest object for SHA384 md = new KJUR.crypto.MessageDigest({alg: "sha384"}); // append data for hash md.updateString("aaa"); // calculate hash nally mdHex = md.digest(); // or use Util class in short. These three will get the same result. mdHex = KJUR.crypto.Util.sha384("aaa"); mdHex = KJUR.crypto.Util.hashString("aaa","sha384"); mdHex = KJUR.crypto.Util.hashHex("616161","sha384");
  • 16. calculate Mac by Mac class calculate message authentication code by Mac class just like Java JCE // generate Mac class mac = new KJUR.crypto.Mac({alg: "HmacSHA256", pass: "pass"}); // append data for Mac mac.updateString('aaa'); // get Mac value macHex = md.doFinal(); pass parameter supports some value formats like this: hexadecimal {hex: "616161"} UTF-8 {utf8: "東京"} Base64 {b64: "Mi02/+...a=="} Base64URL {b64u: "Mi02_-...a"}
  • 18. short ASN.1 introduction ASN.1 is a binary encording of structured data consists of a data type tag(T), byte length(L) and value(V). ASN.1 encoding is used in network protocol or format such like X.509 certi cate, private/public key formats, S/MIME data, digital time stamp, Radius. FEATURE1: variable length data exceeds int or long. FEATURE2: structured data is also available.
  • 19. short ASN.1 introduction (cont'd) Structured data can be represented by SEQUENCE or SET.
  • 21. ASN1HEX basic methods ASN1HEX methods can be used for getting tag, length or value of ASN.1 object of hexadecimal string at speci ed position.
  • 22. ASN1HEX basic methods (cont'd) get a list of indexes of child elements.
  • 23. ASN1HEX for decendant element To refer a decendant element of nested structured ASN.1, use "nthList" which represent indexes for each nested layer. This is very useful to specify a deep nested element such like subject name of X.509 certi cate. getDecendantHexTLVByNthList(s,0,[0,0]) → "020104" getDecendantHexLByNthList(s,0,[0,0]) → "01" getDecendantHexVByNthList(s,0,[0,0]) → "04" getDecendantIndexByNthList(s,0,[0,0]) → 8 ←
  • 25. X509 class Basic fields and extensions can be get by X509 class. x = new X509(); x.readCertPEM(sCertPEM); hex = X.509.pemToHex(sCertPEM); // get subject subject = x.getSubjectString(); // return like "/C=US/O=OTEST" // get subjectAltName san = X.509.getExtSubjectAltName(hex); // return like ["example.com", "example.org"] There are a lot of methods to get elds and extensions. Please see in detail.manual
  • 27. generate and encode ASN.1 (cont'd) Classes for ASN.1 primitives and structured types, as well as X.509 certi cate, CRL, CSR, CMS signed data, digital time stamp and CAdES are de ned in jsrsasign. i1 = new KJUR.asn1.DERInteger({int: 234}); s1 = new KJUR.asn1.DERUTF8String({str: 'Tokyo'}}); seq = new KJUR.asn1.DERSequence({array: [i1, s1]}); hex = seq.getEncodedHex(); Please see in detail. It's very similar to BoucyCastle or IAIK Java ASN.1 classes. However, there is much more easy way... manual
  • 28. generate and encode ASN.1 using newObject It's very easy to generate complicated ASN.1 object by ASN1Util.newObject var hex = new KJUR.asn1.ASN1Util.newObject(   {seq: [              // SEQUENCE      {int: 234},          // INTEGER      {utf8str: 'Tokyo'}      // UTF8String      ]} ).getEncodedHex();
  • 29. get PEM of X.509 certificate by X509Util.newCertPEM It's very easy to generate PEM of X.509 certi cate by . pem = new KJUR.asn1.x509.X509Util.newCertPEM({   serial: {int: 4},   sigalg: {name: 'SHA256withECDSA', paramempty: true},   issuer: {str: '/C=US/O=CA1'},   notbefore: {str: '130504235959Z'}, notafter: {str: '140504235959Z'},   subject: {str: '/C=US/O=T1'},   sbjpubkey: "-----BEGIN PUBLIC KEY...",   ext: [     {basicConstraints: {cA: true, critical: true}},     {keyUsage: {bin: '11'}},   ],   cakey: ["-----BEGIN PRIVATE KEY...", "pass"] }); X509Util.newCertPEM
  • 30. get PEM of PKCS#10/CSRT by CSRUtil.newCSRPEM It's very easy to generate PEM of CSR(certi cate signing request) by . kp = KEYUTIL.generateKeypair("RSA", 2048); pem = new KJUR.asn1.csr.CSRUtil.newCSRPEM({   subject: {str: '/C=US/O=Test/CN=example.com'},   sbjpubkey: kp.pubKeyObj,   sigalg: "SHA256withRSA",   sbjprvkey: kp.prvKeyObj }); CSRUtil.newCSRPEM
  • 32. JWK (JSON Web Key) jsrsasign can load and export RFC 7517 JSON Web Key (JWK). // load JWK jwkPub = {kty: "EC", crv: "P-256", x: "f830J3..." ...}; keyObj = KEYUTIL.getKey(jwkPub); // export to JWK kp = KEYUTIL.generateKeypair("RSA", 2048); jwkPrv = KEYUTIL.getJWKFromKey(kp.prvKeyObj); jwkPub = KEYUTIL.getJWKFromKey(kp.pubKeyObj);
  • 33. JWS (JSON Web Signatures) jsrsasign can sign and verify RFC 7515 JSON Web Signatures (JWS). // sign JWS header = {alg: "HS256"}; payload = {fruit: "orange"}; jws = KJUR.jws.JWS.sign("HS256", header, payload, {utf8: "secret"}); // eyJhbGciOiJIUzI1NiJ9.eyJmcnVpdCI6Im9yYW5nZSJ9. // qbIF5WMbXYMFMh_UXjL2CGts5KPVU7yF7AbOdoyoPZI // verify JWS isValid = KJUR.jws.JWS.verify(jws, {utf8: "secret"}, ["HS256"]); This result can also be veri ed at .jwt.io
  • 35. JWT (JSON Web Token) jsrsasign can sign and verify RFC 7519 JSON Web Token (JWT). // sign JWT header = {alg: "HS256", typ: "JWT"}; payload = {sub: "123456789", name: "John Doe", admin: true}; jwt = KJUR.jws.JWS.sign("HS256", header, payload, {utf8: "secret"}); // eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY // 3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95 // OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ // verify JWT isValid = KJUR.jws.JWS.verifyJWT(jwt, {utf8: "secret"}, {  alg: ["HS256"], sub: ["John Doe"] }); This result can also be veri ed at .jwt.io
  • 36. jsrsasign at jwt.io site have kindly listed jsrsasign. jwt.io provides JWT validator which uses . jwt.io old version of jsrsasign 4.1.5
  • 38. Tools and demos jsrsasign provides a lot of tools which use jsrsasign as example. Please see the as for onliene tools. Also see as for Node tools. As for demonstrations, please see . this list list this list
  • 39. Tutorials jsrsasign provides to make it easy to learn jsrsasign programming. tutorial documents
  • 40. API Reference jsrsasign provides detailed document. API reference also has examples. API Reference