Skip to content

Instantly share code, notes, and snippets.

@maqp
maqp / real_keys.py
Last active January 5, 2021 01:35
Pythagorean factorization in the world of real RSA keys.
import math
import time
from cryptography.hazmat.primitives.asymmetric import rsa
def main():
key_sizes_to_test = [512, 640, 768, 896]
number_of_keys_per_size_to_generate = 10000
I had a chat with a buddy of mine (Topi Talvitie) who's a postdoc researcher here at Helsinki Uni.
He reverse engineered the logic on how a fake solver algorithm, such as the one by Grant's, can be created.
I've tried to to translate it the best I can:
-------------
The goal is to find integers p and q so that pq = N [N being the public key].
The problem is then rephrased so that the goal is to find a single integer C = (p+q) / 2.
This is because finding the value of a single variable appears easier than solving an equation with two variables.
@maqp
maqp / pythagorean_factorization.py
Last active January 4, 2021 06:38
Pythagorean Factorization
#!/usr/bin/env python3.7
# -*- coding: utf-8 -*-
import math
import multiprocessing
import random
import time
from multiprocessing import Queue, Process
from typing import Tuple
@maqp
maqp / sshd_config
Created January 15, 2020 18:14
sshd_config
# Server authentication
Protocol 2
HostKey /etc/ssh/ssh_host_ed25519_key
# Client authentication (Public key of client goes to ~/.ssh/authorized_keys)
PermitEmptyPasswords no
PasswordAuthentication yes
ChallengeResponseAuthentication no
PubkeyAuthentication yes
@maqp
maqp / recoprocal_factoring_efficiency.py
Created October 28, 2019 00:39
Crown Sterling reciprocal factoring method efficiency vs trial division (brute force)
import math
import random
from typing import List
# Let's meet our contestants
def trial_division(semiprime: int):
"""The Faster brute force variant, from Wikipedia:
#!/usr/bin/env python3
import subprocess
import sys
# defining keys & strings to be used
key = "org.gnome.settings-daemon.plugins.media-keys custom-keybindings"
subkey1 = key.replace(" ", ".")[:-1]+":"
item_s = "/"+key.replace(" ", "/").replace(".", "/")+"/"
firstname = "custom"
# get the current list of custom shortcuts
@maqp
maqp / upnote.py
Last active October 21, 2019 22:08
Upnote tool for QOwnnotes
#!/usr/bin/env python3.7
# -*- coding: utf-8 -*-
import shutil
import subprocess
import os
from typing import List, NoReturn, Tuple
debug = True
@maqp
maqp / stemtest.sh
Last active December 15, 2018 15:04
#!/usr/bin/env bash
create_install_dir () {
if [ -d "$HOME/stemtest" ]; then
mv $HOME/stemtest stemtest_backup_at_$(date +%Y-%m-%d_%H-%M-%S)
fi
mkdir -p $HOME/stemtest 2>/dev/null
}
# Install dependencies
#!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
import base64
import hashlib
import os
import random
import shlex
import socket
import subprocess
@maqp
maqp / gist:90a64e9649764b21234ce90367fc7971
Created November 6, 2018 16:37
Riot vs Signal fingerprint read time
import base64
import os
# The durations floats are durations in seconds it took to have Google
# translate pronounce each word. These samples were recorded and the
# duration was measured using Audacity to best of ability.
b10_table = {'0': ('zero ', 0.882),
'1': ('one ', 0.699),
'2': ('two ', 0.718),