Skip to content

Instantly share code, notes, and snippets.

@denji
denji / http-benchmark.md
Last active April 26, 2025 20:16
HTTP(S) Benchmark Tools / Toolkit for testing/debugging HTTP(S) and restAPI (RESTful)
@kurtbrose
kurtbrose / key_wrap.py
Last active December 28, 2022 13:15
implementation of RFC 3394 AES key wrapping/unwrapping
'''
Key wrapping and unwrapping as defined in RFC 3394.
Also a padding mechanism that was used in openssl at one time.
The purpose of this algorithm is to encrypt a key multiple times to add an extra layer of security.
Personally, I wouldn't recommend using this for most applications.
Just use AES/mode CTR to encrypt your keys, the same as you would any other data.
The time to use this code is when you need compatibility with another system that implements the RFC.
(For example, these functions are compatible with the openssl functions of the same name.)
@kurtbrose
kurtbrose / aes_unwrap.py
Created November 30, 2012 01:20
AES key unwrapping as defined in RFC 3394
import struct
from Crypto.Cipher import AES
QUAD = struct.Struct('>Q')
#key wrapping as defined in RFC 3394
#http://www.ietf.org/rfc/rfc3394.txt
def aes_unwrap(kek, wrapped, iv=0xa6a6a6a6a6a6a6a6):
n = len(wrapped)/8 - 1
#NOTE: R[0] is never accessed, left in for consistency with RFC indices