View ssh_certificate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import OrderedDict | |
import paramiko | |
from paramiko.agent import AgentKey | |
from paramiko.message import Message | |
CERT_ATTRIBUTE_TO_TYPE = { | |
'name': 'string', | |
'nonce': 'string', |
View ExponentialBackoff.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExponentialBackoff(object): | |
''' | |
Simple iterator that calculates exponential backoff durations | |
''' | |
def __init__(self, *args, **kwargs): | |
self.initial_interval = kwargs.pop('initial_interval', 5) | |
self.max_interval = kwargs.pop('max_interval', 60) | |
self.randomization_factor = kwargs.pop('randomization_factor', 0.5) | |
self.multiplier = kwargs.pop('multiplier', 1.5) | |
self.max_elapsed_time = kwargs.pop('max_elapsed_time', 900) |
View PollardRho.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from fractions import gcd | |
def pollard_rho(n, seed=2, f=lambda x: x**2 + 1): | |
x, y, d = seed, seed, 1 | |
while d == 1: | |
x = f(x) % n | |
y = f(f(y)) % n | |
d = gcd((x - y) % n, n) |
View NaiveRSA.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import random | |
class NaiveRSA(object): | |
_small_primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97, | |
101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179, | |
181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269, | |
271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367, | |
373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461, | |
463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571, |
View NaiveDiffieHellman.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
class NaiveDiffieHellman(object): | |
'''Naive implementation of the Diffie-Hellman key exchange''' | |
# 3072 bit prime modulus and generator given in RFC3526 | |
# this mod p group has id 14 | |
__P = ('0xFFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1' | |
'29024E088A67CC74020BBEA63B139B22514A08798E3404DD' |