Skip to content

Instantly share code, notes, and snippets.

@maqp
maqp / real_keys.py
Last active Jan 5, 2021
Pythagorean factorization in the world of real RSA keys.
View real_keys.py
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
View gist:ced7e90f70131f95f6465a7f782acf1b
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 Jan 4, 2021
Pythagorean Factorization
View pythagorean_factorization.py
#!/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
View 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 Oct 28, 2019
Crown Sterling reciprocal factoring method efficiency vs trial division (brute force)
View recoprocal_factoring_efficiency.py
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:
View gist:f10dfa9c1b347732453e3bf84f44eaf0
#!/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 Oct 21, 2019
Upnote tool for QOwnnotes
View upnote.py
#!/usr/bin/env python3.7
# -*- coding: utf-8 -*-
import shutil
import subprocess
import os
from typing import List, NoReturn, Tuple
debug = True
View stemtest.sh
#!/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
View v3_onion_test.py
#!/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 Nov 6, 2018
Riot vs Signal fingerprint read time
View gist:90a64e9649764b21234ce90367fc7971
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),
You can’t perform that action at this time.