Skip to content

Instantly share code, notes, and snippets.

@codedust
codedust / readme.md
Last active September 17, 2022 07:51 — forked from panva/readme.md

How to select a JOSE / JWT cryptographic algorithm for your application

The need to secure tokens comes from a number concerns, any of which may apply to your particular use case:

  • Integrity: Verify that the token has not been tampered with
  • Authenticity: The origin of the token can be verified
  • Non-repudiation: The authenticity and integrity of the token is verifiable by third parties
  • Confidentiality: Token payload is kept secret from unauthorized parties

Understanding which security objectives we're after is the first step in selecting an appropriate JOSE algorithm.

<!DOCTYPE html>
<html>
<head>
<script type="module">
import CompactEncrypt from './jose/jwe/compact/encrypt.js'
import CompactDecrypt from './jose/jwe/compact/decrypt.js'
import generateKeyPair from './jose/util/generate_key_pair.js'
import parseJwk from './jose/jwk/parse.js'
const inputElement = document.getElementById("input");
#include <algorithm>
#include <cstring>
#include <iostream>
#include <iomanip>
void printb(const char* title, const unsigned char *buffer, size_t length) {
int indent = (strlen(title) > 6 ? ((strlen(title) + 2) / 6 + 1) * 6 : 7 + 2);
std::cout << title << ":" << std::string(indent - strlen(title) - 2, ' ');
for(size_t i = 0; i < length; i++) {
std::cout << ((i != 0 && i % 16 == 0) ? "\n" + std::string(indent, ' ') : " ");
@codedust
codedust / colorGradient.html
Created February 21, 2019 20:45
Small demo to create a color gradient using javascript
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<script>
// convert decimal values to rgb hex color toRGBstring(255, 0, 0) => '#ff0000')
function toRGBstring(r, g, b) {
return '#' + (r<16?'0':'') + r.toString(16) + (g<16?'0':'') + g.toString(16) + (b<16?'0':'') + b.toString(16);
}
// convert rgb hex color to decimal values (e.g. parseRBGstring('#ff0000') => [255, 0, 0])
@codedust
codedust / nerd2nerd.md
Last active February 19, 2019 17:25
connect to nerd2nerd irc server using weechat

Determine the fingerprint of the server's ssl cert

$ openssl s_client -showcerts -connect irc.nerd2nerd.org:6697 < /dev/null | openssl x509 -sha256 -fingerprint -noout| sed 's/://g'
depth=0 C = DE, ST = Bavaria, L = Wuerzburg, O = Nerd2Nerd, CN = com.nerd2nerd.org, emailAddress = info@nerd2nerd.org                                
verify error:num=18:self signed certificate
verify return:1
depth=0 C = DE, ST = Bavaria, L = Wuerzburg, O = Nerd2Nerd, CN = com.nerd2nerd.org, emailAddress = info@nerd2nerd.org
verify return:1
DONE
SHA256 Fingerprint=4D484E8D5A6C5A8BA279DB2C4DA064D5A78D9D28C398A631E76D06ABA30ECFB7