SlideShare une entreprise Scribd logo
1  sur  26
Télécharger pour lire hors ligne
Javascript Object Signing & Encryption
Aaron Zauner
azet@azet.org
lambda.co.at:
Highly-Available, Scalable & Secure Distributed Systems
DevOps/Security and Web Performance Meetup Vienna -
23/03/2015
Javascript Object Signing & Encryption
Examples
JOSE
Working Group
With the increased usage of JSON in protocols in the IETF and
elsewhere, there is now a desire to offer security services, which use
encryption, digital signatures, message authentication codes (MACs)
algorithms, that carry their data in JSON format.
[. . . ]
This Working Group will standardize the mechanism for integrity
protection (signature and MAC) and encryption as well as the
format for keys and algorithm identifiers to support interoperability
of security services for protocols that use JSON.
https://datatracker.ietf.org/wg/jose/charter/
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 1/24
JOSE
Couple of new IETF standards being worked on to provide a
framework for signatures and/or encryption of JSON data:
JSON Web Key “JWK”
JSON Web Signature “JWS”
JSON Web Encryption “JWE”
(Algorithms defined in JSON Web Algorithms “JWA”)
..it is..
End-to-end (E2E)
Not a replacement for TLS!
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 2/24
JWK: JSON Web Key
Datastructures to represent cryptographic keys
Used for JWS and JWE
Keys and Key-Sets
https://tools.ietf.org/html/draft-ietf-jose-json-web-key
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 3/24
JWK: Key
{"kty":"EC",
"crv":"P-256",
"x":"f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU",
"y":"x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0",
"kid":"Public key used in JWS A.3 example"
}
Key Type: EC (Elliptic Curve, Digital Signature Standard)
Curve: NIST P-256
Curve Points x and y
A Key Identifier kid
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 4/24
JWK: Key
Other parameters that can be assigned include:
use: Public Key Use (sig or enc)
key_ops: allowed operations (sign, verify, enc, dec, et cetera)
alg: Intended Algorithm to be used with this Key
x5u: X.509 URL parameter (certificate resource)
x5c: X.509 Certificate Chain
x5t and x5t#S256: X.509 SHA-1 and SHA-2 Thumbprints
..might sound familiar to X.509 certificate extensions.
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 5/24
JWK: JWK Set (Key Set)
ECC and RSA Public Keys:
{"keys":
[
{"kty":"EC",
"crv":"P-256",
"x":"MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4",
"y":"4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM",
"use":"enc",
"kid":"1"},
{"kty":"RSA",
"n": "0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx
4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMs
tn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65YGjQR0_FDW2
QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n91CbOpbI
SD08qNLyrdkt-bFTWhAI4vMQFh6WeZu0fM4lFd2NcRwr3XPksINHaQ-G_xBniIqb
w0Ls1jF44-csFCur-kEgU8awapJzKnqDKgw",
"e":"AQAB",
"alg":"RS256",
"kid":"2011-04-29"}
]
}
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 6/24
JWK: JWK Set (Key Set)
Set of Symmetric Encryption Keys (AES key wrap and HMAC):
{"keys":
[
{"kty":"oct",
"alg":"A128KW",
"k":"GawgguFyGrWKav7AX4VKUg"},
{"kty":"oct",
"k":"AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-
1qS0gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow",
"kid":"HMAC key used in JWS A.1 example"}
]
}
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 7/24
JWS: JSON Web Signature
Content signed with:
Digital Signature .. or;
Message Authentication Code (MAC)
..thus provides integrity protection.
https://tools.ietf.org/html/draft-ietf-jose-json-web-signature
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 8/24
JWS: JSON Web Signature
JOSE Header (JWS Protected and Unprotected Headers)
JWS Payload
JWS Signature
two serialization formats:
‘compact’: URL-safe (HTTP Auth, URI)
JWS JSON - JSON Objects (values BASE64URL encoded)
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 9/24
JWS: JSON Web Signature
Compact:
BASE64URL(UTF8(JWS Protected Header)) || ‚.‚ ||
BASE64URL(JWS Payload) || ‚.‚ ||
BASE64URL(JWS Signature)
JSON:
{
"payload":"<payload contents>",
"signatures":[
{"protected":"<integrity-protected header 1 contents>",
"header":<non-integrity-protected header 1 contents>,
"signature":"<signature 1 contents>"},
...
{"protected":"<integrity-protected header N contents>",
"header":<non-integrity-protected header N contents>,
"signature":"<signature N contents>"}]
}DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 10/24
JWS: JSON Web Signature
JSON Web Token Example
Header
Object:
{"typ":"JWT",
"alg":"HS256"}
Encoded:
eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 11/24
JWS: JSON Web Signature
JSON Web Token Example
Payload
Object:
{"iss":"joe",
"exp":1300819380,
"http://example.com/is_root":true}
Encoded:
eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQo
gImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 12/24
JWS: JSON Web Signature
JSON Web Token Example
Header
Payload
Signature
..seperated by a dot (.)
Encoded:
eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9
.
eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt
cGxlLmNvbS9pc19yb290Ijp0cnVlfQ
.
dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 13/24
JWS: JSON Web Signature
Header Parameters
alg: Algorithm identifier for JWS
jku: JWK Set URL
jkw: JSON Web Key (JWK)
kid: Key ID
x5u: X.509 URL
x5c: X.509 Chain
x5t and x5t#S256: X.509 Cert. Thumbprint
typ: “Type” (MIME)
cty: Content Type
crit: “Critical” specifies fields that MUST be protected
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 14/24
JWE: JSON Web Encryption
Format is very similar to JWS, but used for encryption of data
BASE64URL(UTF8(JWE Protected Header)) || ‚.‚ ||
BASE64URL(JWE Encrypted Key) || ‚.‚ ||
BASE64URL(JWE Initialization Vector) || ‚.‚ ||
BASE64URL(JWE Ciphertext) || ‚.‚ ||
BASE64URL(JWE Authentication Tag)
https://tools.ietf.org/html/draft-ietf-jose-json-web-encryption
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 15/24
JWE: JSON Web Encryption
Header Parameters
alg: Algorithm identifier for JWE
enc: Content Encryption Algorithm
zip: Compression algorithm to be used
jku: JWK Set URL
jkw: JSON Web Key (JWK)
kid: Key ID
x5u: X.509 URL
x5c: X.509 Chain
x5t and x5t#S256: X.509 Cert. Thumbprint
typ: “Type” (MIME)
cty: Content Type
crit: “Critical” specifies fields that MUST be protected
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 16/24
JWE: JSON Web Encryption
Example (flattened JSON representation):
{
"protected":
"eyJlbmMiOiJBMTI4Q0JDLUhTMjU2In0",
"unprotected":
{"jku":"https://server.example.com/keys.jwks"},
"header":
{"alg":"A128KW","kid":"7"},
"encrypted_key":
"6KB707dM9YTIgHtLvtgWQ8mKwboJW3of9locizkDTHzBC2IlrT1oOQ",
"iv":
"AxY8DCtDaGlsbGljb3RoZQ",
"ciphertext":
"KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY",
"tag":
"Mz-VPPyU4RlcuYv1IwIvzw"
}
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 17/24
JWA: JSON Web Algorithms
JWA Specifies a list of crypto primitives (algorithms) to be used
in conjunction with JOSE and their parameters
Not going into that in this talk. Some of them you’ve already
seen in previous examples, if you want more details on the
algorithms that can be used look into the draft
DON’T home-brew your own crypto with these. Use existing,
verified, technologies that build on JOSE
https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 18/24
Running Code
Implementations in all popular languages are available on GitHub!
Python
import jose
claims = {
"iss": "http://www.example.com",
"exp": int(time()) + 3600,
"sub": 42,
}
jwk = {"k": "password"}
jws = jose.sign(claims, jwk, alg="HS256")
http://jose.readthedocs.org/en/latest/
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 19/24
Authentication Protocols
OAuth
OpenID / OAuth2.0
..client authentication and authorization can be handeled by JOSE /
Web Tokens entirely.
See:
https://tools.ietf.org/html/draft-ietf-oauth-jwt-bearer
https://developers.google.com/accounts/docs/OpenIDConnect
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 20/24
Google Wallet
Google Wallet uses JWT to exchange information between
clients (app) and Server
https://developers.google.com/wallet/instant-buy/about-jwts
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 21/24
ACME / Let’s Encrypt
The protocol that Let’s Encrypt employs (ACME) uses JOSE for
messaging
i.e. claims for certificates / domains and revocation
https://letsencrypt.github.io/acme-spec/
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 22/24
W3C WebCrypto
W3C WebCrypto is a JavaScript API for performing basic
cryptographic operations in web applications
W3C WebCrypto employs JOSE (Key Format, Signatures,
Algorithms)
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 23/24
Thanks for your patience. Are there any questions?
Twitter:
@a_z_e_t
E-Mail:
azet@azet.org
XMPP:
azet@jabber.ccc.de
GitHub:
https://github.com/azet
GPG Fingerprint:
7CB6 197E 385A 02DC 15D8 E223 E4DB 6492 FDB9 B5D5
DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption
Aaron Zauner 24/24

Contenu connexe

Tendances

JSON Web Tokens Will Improve Your Life
JSON Web Tokens Will Improve Your LifeJSON Web Tokens Will Improve Your Life
JSON Web Tokens Will Improve Your Life
John Anderson
 
MongoDB + Java + Spring Data
MongoDB + Java + Spring DataMongoDB + Java + Spring Data
MongoDB + Java + Spring Data
Anton Sulzhenko
 

Tendances (20)

MongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 Link
MongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 LinkMongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 Link
MongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 Link
 
JSON Web Tokens Will Improve Your Life
JSON Web Tokens Will Improve Your LifeJSON Web Tokens Will Improve Your Life
JSON Web Tokens Will Improve Your Life
 
Session 5 - NGSI-LD Advanced Operations | Train the Trainers Program
Session 5 -  NGSI-LD Advanced Operations | Train the Trainers ProgramSession 5 -  NGSI-LD Advanced Operations | Train the Trainers Program
Session 5 - NGSI-LD Advanced Operations | Train the Trainers Program
 
Understanding JWT Exploitation
Understanding JWT ExploitationUnderstanding JWT Exploitation
Understanding JWT Exploitation
 
Cargo Cult Security UJUG Sep2015
Cargo Cult Security UJUG Sep2015Cargo Cult Security UJUG Sep2015
Cargo Cult Security UJUG Sep2015
 
Autenticação com Json Web Token (JWT)
Autenticação com Json Web Token (JWT)Autenticação com Json Web Token (JWT)
Autenticação com Json Web Token (JWT)
 
MongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local Munich 2019: Tips and Tricks++ for Querying and Indexing MongoDB
 
Distributed Identities with OpenID
Distributed Identities with OpenIDDistributed Identities with OpenID
Distributed Identities with OpenID
 
JSON Web Tokens Will Improve Your Life
JSON Web Tokens Will Improve Your LifeJSON Web Tokens Will Improve Your Life
JSON Web Tokens Will Improve Your Life
 
Data Modeling with NGSI, NGSI-LD
Data Modeling with NGSI, NGSI-LDData Modeling with NGSI, NGSI-LD
Data Modeling with NGSI, NGSI-LD
 
Breaking vaults: Stealing Lastpass protected secrets
Breaking vaults: Stealing Lastpass protected secretsBreaking vaults: Stealing Lastpass protected secrets
Breaking vaults: Stealing Lastpass protected secrets
 
Blockchain Technologies for Data Science
Blockchain Technologies for Data ScienceBlockchain Technologies for Data Science
Blockchain Technologies for Data Science
 
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers ProgramSession 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
 
A XSSmas carol
A XSSmas carolA XSSmas carol
A XSSmas carol
 
MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know
 
Cryptography 101 for Java Developers - Devoxx 2019
Cryptography 101 for Java Developers - Devoxx 2019Cryptography 101 for Java Developers - Devoxx 2019
Cryptography 101 for Java Developers - Devoxx 2019
 
Honing headers for highly hardened highspeed hypertext
Honing headers for highly hardened highspeed hypertextHoning headers for highly hardened highspeed hypertext
Honing headers for highly hardened highspeed hypertext
 
Cryptography in PHP: use cases
Cryptography in PHP: use casesCryptography in PHP: use cases
Cryptography in PHP: use cases
 
Cryptography 101 for Java Developers - JavaZone2019
Cryptography 101 for Java Developers - JavaZone2019Cryptography 101 for Java Developers - JavaZone2019
Cryptography 101 for Java Developers - JavaZone2019
 
MongoDB + Java + Spring Data
MongoDB + Java + Spring DataMongoDB + Java + Spring Data
MongoDB + Java + Spring Data
 

Similaire à Javascript Object Signing & Encryption

Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
FIWARE
 
HTML5 (and friends) - History, overview and current status - jsDay Verona 11....
HTML5 (and friends) - History, overview and current status - jsDay Verona 11....HTML5 (and friends) - History, overview and current status - jsDay Verona 11....
HTML5 (and friends) - History, overview and current status - jsDay Verona 11....
Patrick Lauke
 
Nk API - examples
Nk API - examplesNk API - examples
Nk API - examples
nasza-klasa
 
FIWARE Training: IoT and Legacy
FIWARE Training: IoT and LegacyFIWARE Training: IoT and Legacy
FIWARE Training: IoT and Legacy
FIWARE
 

Similaire à Javascript Object Signing & Encryption (20)

Securing TodoMVC Using the Web Cryptography API
Securing TodoMVC Using the Web Cryptography APISecuring TodoMVC Using the Web Cryptography API
Securing TodoMVC Using the Web Cryptography API
 
Java script and web cryptography (cf.objective)
Java script and web cryptography (cf.objective)Java script and web cryptography (cf.objective)
Java script and web cryptography (cf.objective)
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
 
HTML5 (and friends) - History, overview and current status - jsDay Verona 11....
HTML5 (and friends) - History, overview and current status - jsDay Verona 11....HTML5 (and friends) - History, overview and current status - jsDay Verona 11....
HTML5 (and friends) - History, overview and current status - jsDay Verona 11....
 
[Poland] It's only about frontend
[Poland] It's only about frontend[Poland] It's only about frontend
[Poland] It's only about frontend
 
iMasters Intercon 2016 - Identity within Microservices
iMasters Intercon 2016 - Identity within MicroservicesiMasters Intercon 2016 - Identity within Microservices
iMasters Intercon 2016 - Identity within Microservices
 
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
 
sf bay area dfir meetup (2016-04-30) - OsxCollector
sf bay area dfir meetup (2016-04-30) - OsxCollector   sf bay area dfir meetup (2016-04-30) - OsxCollector
sf bay area dfir meetup (2016-04-30) - OsxCollector
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
 
Best Practices of IoT in the Cloud
Best Practices of IoT in the CloudBest Practices of IoT in the Cloud
Best Practices of IoT in the Cloud
 
HTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the WebHTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the Web
 
Best Practices for IoT Security in the Cloud
Best Practices for IoT Security in the CloudBest Practices for IoT Security in the Cloud
Best Practices for IoT Security in the Cloud
 
Nk API - examples
Nk API - examplesNk API - examples
Nk API - examples
 
Browser security
Browser securityBrowser security
Browser security
 
RoadSec 2017 - Trilha AppSec - APIs Authorization
RoadSec 2017 - Trilha AppSec - APIs AuthorizationRoadSec 2017 - Trilha AppSec - APIs Authorization
RoadSec 2017 - Trilha AppSec - APIs Authorization
 
OpenStack APIs: Present and Future (Beta Talk)
OpenStack APIs: Present and Future (Beta Talk)OpenStack APIs: Present and Future (Beta Talk)
OpenStack APIs: Present and Future (Beta Talk)
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
FIWARE Training: IoT and Legacy
FIWARE Training: IoT and LegacyFIWARE Training: IoT and Legacy
FIWARE Training: IoT and Legacy
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
Life on Clouds: a forensics overview
Life on Clouds: a forensics overviewLife on Clouds: a forensics overview
Life on Clouds: a forensics overview
 

Plus de Aaron Zauner

State of Transport Security in the E-Mail Ecosystem at Large
State of Transport Security in the E-Mail Ecosystem at LargeState of Transport Security in the E-Mail Ecosystem at Large
State of Transport Security in the E-Mail Ecosystem at Large
Aaron Zauner
 
Introduction to and survey of TLS security (BsidesHH 2014)
Introduction to and survey of TLS security (BsidesHH 2014)Introduction to and survey of TLS security (BsidesHH 2014)
Introduction to and survey of TLS security (BsidesHH 2014)
Aaron Zauner
 
Introduction to and survey of TLS Security
Introduction to and survey of TLS SecurityIntroduction to and survey of TLS Security
Introduction to and survey of TLS Security
Aaron Zauner
 
How to save the environment
How to save the environmentHow to save the environment
How to save the environment
Aaron Zauner
 

Plus de Aaron Zauner (13)

Because "use urandom" isn't everything: a deep dive into CSPRNGs in Operating...
Because "use urandom" isn't everything: a deep dive into CSPRNGs in Operating...Because "use urandom" isn't everything: a deep dive into CSPRNGs in Operating...
Because "use urandom" isn't everything: a deep dive into CSPRNGs in Operating...
 
[BlackHat USA 2016] Nonce-Disrespecting Adversaries: Practical Forgery Attack...
[BlackHat USA 2016] Nonce-Disrespecting Adversaries: Practical Forgery Attack...[BlackHat USA 2016] Nonce-Disrespecting Adversaries: Practical Forgery Attack...
[BlackHat USA 2016] Nonce-Disrespecting Adversaries: Practical Forgery Attack...
 
No need for Black Chambers: Testing TLS in the E-Mail Ecosystem at Large (hac...
No need for Black Chambers: Testing TLS in the E-Mail Ecosystem at Large (hac...No need for Black Chambers: Testing TLS in the E-Mail Ecosystem at Large (hac...
No need for Black Chambers: Testing TLS in the E-Mail Ecosystem at Large (hac...
 
State of Transport Security in the E-Mail Ecosystem at Large
State of Transport Security in the E-Mail Ecosystem at LargeState of Transport Security in the E-Mail Ecosystem at Large
State of Transport Security in the E-Mail Ecosystem at Large
 
Introduction to and survey of TLS security (BsidesHH 2014)
Introduction to and survey of TLS security (BsidesHH 2014)Introduction to and survey of TLS security (BsidesHH 2014)
Introduction to and survey of TLS security (BsidesHH 2014)
 
Beautiful Bash: Let's make reading and writing bash scripts fun again!
Beautiful Bash: Let's make reading and writing bash scripts fun again!Beautiful Bash: Let's make reading and writing bash scripts fun again!
Beautiful Bash: Let's make reading and writing bash scripts fun again!
 
Introduction to and survey of TLS Security
Introduction to and survey of TLS SecurityIntroduction to and survey of TLS Security
Introduction to and survey of TLS Security
 
[IETF Part] BetterCrypto Workshop @ Hack.lu 2014
[IETF Part] BetterCrypto Workshop @ Hack.lu 2014[IETF Part] BetterCrypto Workshop @ Hack.lu 2014
[IETF Part] BetterCrypto Workshop @ Hack.lu 2014
 
[Attacks Part] BetterCrypto Workshop @ Hack.lu 2014
[Attacks Part] BetterCrypto Workshop @ Hack.lu 2014 [Attacks Part] BetterCrypto Workshop @ Hack.lu 2014
[Attacks Part] BetterCrypto Workshop @ Hack.lu 2014
 
Introduction to and survey of TLS Security
Introduction to and survey of TLS SecurityIntroduction to and survey of TLS Security
Introduction to and survey of TLS Security
 
BetterCrypto: Applied Crypto Hardening
BetterCrypto: Applied Crypto HardeningBetterCrypto: Applied Crypto Hardening
BetterCrypto: Applied Crypto Hardening
 
How to save the environment
How to save the environmentHow to save the environment
How to save the environment
 
Sc12 workshop-writeup
Sc12 workshop-writeupSc12 workshop-writeup
Sc12 workshop-writeup
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 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...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
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
 
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...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

Javascript Object Signing & Encryption

  • 1. Javascript Object Signing & Encryption Aaron Zauner azet@azet.org lambda.co.at: Highly-Available, Scalable & Secure Distributed Systems DevOps/Security and Web Performance Meetup Vienna - 23/03/2015
  • 2. Javascript Object Signing & Encryption Examples
  • 3. JOSE Working Group With the increased usage of JSON in protocols in the IETF and elsewhere, there is now a desire to offer security services, which use encryption, digital signatures, message authentication codes (MACs) algorithms, that carry their data in JSON format. [. . . ] This Working Group will standardize the mechanism for integrity protection (signature and MAC) and encryption as well as the format for keys and algorithm identifiers to support interoperability of security services for protocols that use JSON. https://datatracker.ietf.org/wg/jose/charter/ DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 1/24
  • 4. JOSE Couple of new IETF standards being worked on to provide a framework for signatures and/or encryption of JSON data: JSON Web Key “JWK” JSON Web Signature “JWS” JSON Web Encryption “JWE” (Algorithms defined in JSON Web Algorithms “JWA”) ..it is.. End-to-end (E2E) Not a replacement for TLS! DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 2/24
  • 5. JWK: JSON Web Key Datastructures to represent cryptographic keys Used for JWS and JWE Keys and Key-Sets https://tools.ietf.org/html/draft-ietf-jose-json-web-key DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 3/24
  • 6. JWK: Key {"kty":"EC", "crv":"P-256", "x":"f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU", "y":"x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0", "kid":"Public key used in JWS A.3 example" } Key Type: EC (Elliptic Curve, Digital Signature Standard) Curve: NIST P-256 Curve Points x and y A Key Identifier kid DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 4/24
  • 7. JWK: Key Other parameters that can be assigned include: use: Public Key Use (sig or enc) key_ops: allowed operations (sign, verify, enc, dec, et cetera) alg: Intended Algorithm to be used with this Key x5u: X.509 URL parameter (certificate resource) x5c: X.509 Certificate Chain x5t and x5t#S256: X.509 SHA-1 and SHA-2 Thumbprints ..might sound familiar to X.509 certificate extensions. DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 5/24
  • 8. JWK: JWK Set (Key Set) ECC and RSA Public Keys: {"keys": [ {"kty":"EC", "crv":"P-256", "x":"MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4", "y":"4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM", "use":"enc", "kid":"1"}, {"kty":"RSA", "n": "0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx 4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMs tn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65YGjQR0_FDW2 QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n91CbOpbI SD08qNLyrdkt-bFTWhAI4vMQFh6WeZu0fM4lFd2NcRwr3XPksINHaQ-G_xBniIqb w0Ls1jF44-csFCur-kEgU8awapJzKnqDKgw", "e":"AQAB", "alg":"RS256", "kid":"2011-04-29"} ] } DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 6/24
  • 9. JWK: JWK Set (Key Set) Set of Symmetric Encryption Keys (AES key wrap and HMAC): {"keys": [ {"kty":"oct", "alg":"A128KW", "k":"GawgguFyGrWKav7AX4VKUg"}, {"kty":"oct", "k":"AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T- 1qS0gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow", "kid":"HMAC key used in JWS A.1 example"} ] } DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 7/24
  • 10. JWS: JSON Web Signature Content signed with: Digital Signature .. or; Message Authentication Code (MAC) ..thus provides integrity protection. https://tools.ietf.org/html/draft-ietf-jose-json-web-signature DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 8/24
  • 11. JWS: JSON Web Signature JOSE Header (JWS Protected and Unprotected Headers) JWS Payload JWS Signature two serialization formats: ‘compact’: URL-safe (HTTP Auth, URI) JWS JSON - JSON Objects (values BASE64URL encoded) DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 9/24
  • 12. JWS: JSON Web Signature Compact: BASE64URL(UTF8(JWS Protected Header)) || ‚.‚ || BASE64URL(JWS Payload) || ‚.‚ || BASE64URL(JWS Signature) JSON: { "payload":"<payload contents>", "signatures":[ {"protected":"<integrity-protected header 1 contents>", "header":<non-integrity-protected header 1 contents>, "signature":"<signature 1 contents>"}, ... {"protected":"<integrity-protected header N contents>", "header":<non-integrity-protected header N contents>, "signature":"<signature N contents>"}] }DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 10/24
  • 13. JWS: JSON Web Signature JSON Web Token Example Header Object: {"typ":"JWT", "alg":"HS256"} Encoded: eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 11/24
  • 14. JWS: JSON Web Signature JSON Web Token Example Payload Object: {"iss":"joe", "exp":1300819380, "http://example.com/is_root":true} Encoded: eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQo gImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 12/24
  • 15. JWS: JSON Web Signature JSON Web Token Example Header Payload Signature ..seperated by a dot (.) Encoded: eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 . eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt cGxlLmNvbS9pc19yb290Ijp0cnVlfQ . dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 13/24
  • 16. JWS: JSON Web Signature Header Parameters alg: Algorithm identifier for JWS jku: JWK Set URL jkw: JSON Web Key (JWK) kid: Key ID x5u: X.509 URL x5c: X.509 Chain x5t and x5t#S256: X.509 Cert. Thumbprint typ: “Type” (MIME) cty: Content Type crit: “Critical” specifies fields that MUST be protected DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 14/24
  • 17. JWE: JSON Web Encryption Format is very similar to JWS, but used for encryption of data BASE64URL(UTF8(JWE Protected Header)) || ‚.‚ || BASE64URL(JWE Encrypted Key) || ‚.‚ || BASE64URL(JWE Initialization Vector) || ‚.‚ || BASE64URL(JWE Ciphertext) || ‚.‚ || BASE64URL(JWE Authentication Tag) https://tools.ietf.org/html/draft-ietf-jose-json-web-encryption DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 15/24
  • 18. JWE: JSON Web Encryption Header Parameters alg: Algorithm identifier for JWE enc: Content Encryption Algorithm zip: Compression algorithm to be used jku: JWK Set URL jkw: JSON Web Key (JWK) kid: Key ID x5u: X.509 URL x5c: X.509 Chain x5t and x5t#S256: X.509 Cert. Thumbprint typ: “Type” (MIME) cty: Content Type crit: “Critical” specifies fields that MUST be protected DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 16/24
  • 19. JWE: JSON Web Encryption Example (flattened JSON representation): { "protected": "eyJlbmMiOiJBMTI4Q0JDLUhTMjU2In0", "unprotected": {"jku":"https://server.example.com/keys.jwks"}, "header": {"alg":"A128KW","kid":"7"}, "encrypted_key": "6KB707dM9YTIgHtLvtgWQ8mKwboJW3of9locizkDTHzBC2IlrT1oOQ", "iv": "AxY8DCtDaGlsbGljb3RoZQ", "ciphertext": "KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY", "tag": "Mz-VPPyU4RlcuYv1IwIvzw" } DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 17/24
  • 20. JWA: JSON Web Algorithms JWA Specifies a list of crypto primitives (algorithms) to be used in conjunction with JOSE and their parameters Not going into that in this talk. Some of them you’ve already seen in previous examples, if you want more details on the algorithms that can be used look into the draft DON’T home-brew your own crypto with these. Use existing, verified, technologies that build on JOSE https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 18/24
  • 21. Running Code Implementations in all popular languages are available on GitHub! Python import jose claims = { "iss": "http://www.example.com", "exp": int(time()) + 3600, "sub": 42, } jwk = {"k": "password"} jws = jose.sign(claims, jwk, alg="HS256") http://jose.readthedocs.org/en/latest/ DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 19/24
  • 22. Authentication Protocols OAuth OpenID / OAuth2.0 ..client authentication and authorization can be handeled by JOSE / Web Tokens entirely. See: https://tools.ietf.org/html/draft-ietf-oauth-jwt-bearer https://developers.google.com/accounts/docs/OpenIDConnect DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 20/24
  • 23. Google Wallet Google Wallet uses JWT to exchange information between clients (app) and Server https://developers.google.com/wallet/instant-buy/about-jwts DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 21/24
  • 24. ACME / Let’s Encrypt The protocol that Let’s Encrypt employs (ACME) uses JOSE for messaging i.e. claims for certificates / domains and revocation https://letsencrypt.github.io/acme-spec/ DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 22/24
  • 25. W3C WebCrypto W3C WebCrypto is a JavaScript API for performing basic cryptographic operations in web applications W3C WebCrypto employs JOSE (Key Format, Signatures, Algorithms) DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 23/24
  • 26. Thanks for your patience. Are there any questions? Twitter: @a_z_e_t E-Mail: azet@azet.org XMPP: azet@jabber.ccc.de GitHub: https://github.com/azet GPG Fingerprint: 7CB6 197E 385A 02DC 15D8 E223 E4DB 6492 FDB9 B5D5 DevOps/Security and Web Performance Meetup Vienna - 23/03/2015 Javascript Object Signing & Encryption Aaron Zauner 24/24