Skip to content

Instantly share code, notes, and snippets.

Lifetimes of cryptographic hash functions

I've written some cautionary articles on using cryptographic hashes to create content-based addresses (compare-by-hash). This page brings together everything I've written and keeps an updated table of the status of popular cryptographic hash functions. Quick summary of my recommendations on compare-by-hash: If you are using compare-by-hash to generate addresses for data that can be supplied by malicious users, you should have a plan to migrate to a new hash every few years. For example, BitTorrent falls into this category, but rsync doesn't. Keep in mind that new, more secure hashes are likely to have larger outputs (e.g., 256 bits for SHA-2 vs. 160 bits for SHA-1) and be more computationally expensive.

An Analysis of Compare-by-hash appeared in Hot Topics in Operating Systems 2003 The original paper casting doubt on compare-by-hash as the answer to all of life's problems.

FOCAL: AYRIE,LANTS,KEMBO,VIFDA,FOCAL
CIGAR: ANOLE,TRAYS,HAMBA,FOCAL,CIGAR
NAVAL: AYRIE,COLTS,POUND,REBUT,NAVAL
REBUT: ALOES,DRICE,KEMPY,VANTS,REBUT
DWARF: ANOLE,SATYR,CRUMP,HUMPH,DWARF
SISSY: REALO,DUCTS,KNISH,HUMPH,SISSY
HUMPH: ARISE,COULD,FUNGO,YMPES,HUMPH
BLUSH: ATONE,DRIPS,SUSHI,FOCAL,BLUSH
KARMA: ANOLE,TRAYS,HIJAB,AWAKE,KARMA
BENCH: ALOES,DIRGE,THEFT,AWAKE,BENCH
@m1el
m1el / interrupt.rs
Last active November 3, 2021 15:46
#![feature(naked_functions)]
#![no_std]
#![no_main]
use esp8266_hal::prelude::*;
use esp8266_hal::interrupt::{enable_interrupt, disable_interrupt, InterruptType};
use esp8266_hal::gpio::InterruptMode;
use esp8266_hal::target::{self, Peripherals};
use core::fmt::Write;
use core::sync::atomic::{AtomicUsize, Ordering};
card:
dates:
- 28.06.1996
id: 254к/96-вр
issuers:
- name: Верховна Рада України
numbers:
- 254к/96-ВР
state:
- Чинний
#![feature(platform_intrinsics)]
#![feature(portable_simd)]
use core_simd::*;
extern "platform-intrinsic" {
fn simd_cast<T,U>(x: T) -> U;
}
fn cast_16_32<const LANES: usize>(x: Simd<u16, LANES>) -> Simd<u32, LANES>
where LaneCount<LANES>: SupportedLaneCount
@m1el
m1el / ord_reverse.py
Last active May 29, 2021 20:24
Python wrapper for reverse ordering of a value.
class Reverse(object):
'''
Wrapper for reverse ordering of a value.
Usage:
array = [1, 2, 3, 4]
array.sort(key=Reverse)
# [4, 3, 2, 1]
from collections import namedtuple
/// Permutes the `slice` into the next permutation, where the set of all
/// permutations is ordered lexicographically.
/// Returns `true` if there is a next permutation.
///
/// # Example
/// ```rust
/// let mut values: Vec<usize> = (0..3).collect();
/// while next_permutation(&mut values) {
/// println!("current permutation: {:?}", values);
/// }
[package]
name = "round"
version = "0.1.0"
authors = ["Igor null <m1el.2027@gmail.com>"]
[dependencies]
libm = "0.1.2"
[[bin]]
name = "round-bench"
@m1el
m1el / sdist.plt
Last active March 28, 2021 17:05
sdutils
set term svg
set output 'sdist_under.svg'
set xrange [-4:4]
set yrange [0:0.45]
set samples 1000
plot \
x < 1 ? exp(-x*x/2)/sqrt(6.283185307179586) : 1/0 with filledcurves x1 lc rgb "grey", \
exp(-x*x/2)/sqrt(6.283185307179586) lw 2 lc rgb "black"
set output 'sdist_inside.svg'
from collections import defaultdict
from itertools import permutations
from pprint import pprint
# this is going to calculate the output of the game
# the number of colors guessed correctly and the number of
# colors placed correctly
def calculate_score(correct, guess):
correct_colors = sum(1 for color in guess if color in correct)
correct_place = sum(1 for (a, b) in zip(correct, guess) if a == b)
return (correct_colors - correct_place, correct_place)