Skip to content

Instantly share code, notes, and snippets.

View jedisct1's full-sized avatar

Frank Denis jedisct1

View GitHub Profile
@jedisct1
jedisct1 / sign.go
Last active February 13, 2025 09:34
SIgning a CSR in Go, for mTLS (using ECDSA keys)
// Create a key pair for the app and a CSR:
// $ openssl ecparam -genkey -name prime256v1 -out application.key
// $ openssl req -new -sha256 -key application.key -out request.csr
package main
import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
@jedisct1
jedisct1 / compiling-c-to-webassembly-and-rust.md
Last active January 11, 2025 07:18
Compiling C code to WebAssembly and Rust

How to embed C/C++ code in a Rust project targeting WebAssembly

When targeting WebAssembly, C/C++ code can be compiled as a library, and then get statically linked to a Rust project.

Step 1

Install the Zig toolchain in order to compile C and C++ code to WebAssembly.

zig cc is available for many platforms including Windows, and makes it easy to switch back and forth between native and wasm targets. WebAssembly is a Tier-1 target, and it was successfully used to port libraries such as ffmpeg, zlib, openssl, boringssl and libsodium.

@jedisct1
jedisct1 / foo.go
Last active January 3, 2025 18:01
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"fmt"
"log"
"os"
@jedisct1
jedisct1 / b.rs
Last active September 17, 2024 14:48
// Cargo.toml:
// [dependencies]
// boring = { package = "superboring", version = "0.1.2" }
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Ciphertext
let ciphertext = include_bytes!("signed_message.bin");
// Unencrypted RSA private key in PEM format
let rsa_pem = include_str!("sessionprivatekey.pem");
@jedisct1
jedisct1 / a.rs
Created September 17, 2024 14:45
// Cargo.toml:
// [dependencies]
// rsa = "0.9.6"
// rand = "0.8.5"
fn main() -> Result<(), Box<dyn std::error::Error>> {
use rsa::pkcs8::DecodePrivateKey as _;
// Ciphertext
let ciphertext = include_bytes!("signed_message.bin");
$ redis-cli -h debaser keys '*paypal*'
paypal.com.0.security-confirmation.88052b22c8c2349c0599bd39a654c534.343.2u.se. A
paypal.com.cgi.bin.webscr.cmd.login.submit.dispatch.5105241541858541524185418541854104524158234.printanario.pt. A
abgleich-paypal.e7.to. A
paypal.com.login.webscr.flow.session.kf95piozhyz4mvqgf5q.dispatch.588fef.b7e9fe6.ku.52rt54gh4s6h54fd5h46rd54h6df54.h65sf465.hhg465sf4t6j5s4y6.n54q6sr54g6ez54h6q54tej5r646jr84y654nd6fsqj5r646jr84y654nd6f.animaedu.com. A
myaccount.online.paypal.comafraidgerty.ns360.info. A
paypalcraze.com. A
checker-paypal.tk. A
secure.paypalsecurity980222.cf. A
use flate2::Compression;
use std::io::prelude::*;
use benchmark_simple::*;
fn memusage() -> usize {
#[cfg(target_arch = "wasm32")]
let z = core::arch::wasm32::memory_grow(0, 0);
#[cfg(not(target_arch = "wasm32"))]
package main
import (
"crypto/aes"
"net"
)
func EncryptIp(key []byte, ip net.IP) net.IP {
cipher, err := aes.NewCipher(key)
if err != nil {
@jedisct1
jedisct1 / pureftpd shellshock.txt
Last active August 8, 2023 20:07
Pure-FTPd + external authentication handler #shellshock POC
$ cat > /tmp/handler.sh
#! /bin/bash
echo auth_ok:1
echo uid:42
echo gid:21
echo dir:/tmp
echo end
^D
$ chmod +x /tmp/handler.sh

std.crypto changes

New features

  • Salsa20: round-reduced variants can now be used.
  • The POLYVAL universal hash function was added.
  • AEGIS: support for 256-bit tags was added.
  • A MAC API was added to AEGIS (std.crypto.auth.aegis) - AEGIS can be used as a high-performance MAC on systems with hardware AES support. Note that this is not a hash function; a secret key is absolutely required in order to authenticate untrusted messages.
  • Edwards25519: a rejectLowOrder() function was added to quickly reject low-order points.
  • HKDF: with extractInit(), a PRK can now be initialized with only a salt, the keying material being added later, possibly as multiple chunks.