Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/RsaCtfTool/RsaCtfTool
/ functions
Functions
614 in github.com/RsaCtfTool/RsaCtfTool
⨍
Functions
614
◇
Types & classes
177
↓ 29 callers
Function
_run
(*args, timeout=60)
tests/test_attacks.py:14
↓ 17 callers
Method
create_private_key_from_pqe
Helper method to create a private key from p, q, e, n values Args: p: prime factor p q: prime factor q e:
src/RsaCtfTool/attacks/abstract_attack.py:88
↓ 11 callers
Function
get_numeric_value
Parse input (hex or numerical)
src/RsaCtfTool/lib/utils.py:23
↓ 9 callers
Function
binary_search
Finds item index in O(log2(N))
src/RsaCtfTool/lib/utils.py:229
↓ 9 callers
Method
create_private_key
Helper method to create a private key from publickey with p and q Args: publickey: PublicKey object with n, e, p, q attributes
src/RsaCtfTool/attacks/abstract_attack.py:64
↓ 8 callers
Function
_build_qs_factor_base
Build QS factor base: -1 + primes (from first B primes). Every prime p <= the B-th prime is included. Sieving roots: - p = 2 →
src/RsaCtfTool/lib/algos.py:287
↓ 8 callers
Function
generate_keys_from_p_q_e_n
Generate keypair from p, q, e, n
src/RsaCtfTool/lib/keys_wrapper.py:52
↓ 8 callers
Function
legendre
Legendre symbol (a/p) for odd prime p. Returns 0 if p|a, 1 if a is a quadratic residue mod p, p-1 (≡ -1) if QNR. Uses Euler's criterion: a^((p
src/RsaCtfTool/lib/number_theory.py:450
↓ 7 callers
Function
_gaussian_elimination_gf2
Gaussian elimination over GF(2) with pivot tracking. Each element of *rows* is (bitmask, relation_mask). Returns the transformed list in red
src/RsaCtfTool/lib/algos.py:198
↓ 7 callers
Method
decrypt
Decrypt data with private key :param cipher: input cipher :type cipher: string
src/RsaCtfTool/lib/keys_wrapper.py:199
↓ 7 callers
Function
dixon
Dixon's smooth-number factorisation (Dixon, Math. Comp. 36, 1981). Collects relations a_i² ≡ ∏ pⱼ^{e_{ij}} (mod n) that are B-smooth, solves a
src/RsaCtfTool/lib/algos.py:251
↓ 7 callers
Function
quadratic_sieve
Quadratic Sieve factorisation. Complexity: L[1/2, 1] = exp(sqrt(log n log log n)). Sieves Q(x) = x^2 - n for B-smooth values, then reuses th
src/RsaCtfTool/lib/algos.py:357
↓ 6 callers
Function
digit_sum
Compute sum of digits efficiently without string conversion.
src/RsaCtfTool/lib/number_theory.py:39
↓ 6 callers
Method
get_name
Return attack name
src/RsaCtfTool/attacks/abstract_attack.py:21
↓ 6 callers
Function
list_prod
(list_)
src/RsaCtfTool/lib/number_theory.py:33
↓ 6 callers
Function
miller_rabin
" Taken from https://gist.github.com/Ayrx/5884790 Implementation uses the Miller-Rabin Primality Test The optimal number of rounds for th
src/RsaCtfTool/lib/number_theory.py:179
↓ 6 callers
Function
mulmod
(a, b, m)
src/RsaCtfTool/lib/number_theory.py:64
↓ 6 callers
Function
s2n
String to number.
src/RsaCtfTool/lib/utils.py:211
↓ 5 callers
Function
_qs_sieve_interval
Sieve Q(x) = x^2 - n over x in [sqrt(n)-M, sqrt(n)+M]. Returns list of (x, parity_mask, full_exp) relations compatible with _try_smooth_depen
src/RsaCtfTool/lib/algos.py:316
↓ 5 callers
Function
rational_to_contfrac
Rational_to_contfrac implementation
src/RsaCtfTool/lib/number_theory.py:591
↓ 4 callers
Function
A007814
(n)
src/RsaCtfTool/lib/number_theory.py:51
↓ 4 callers
Method
attack_single_key
Run attacks on single keys
src/RsaCtfTool/lib/rsa_attack.py:373
↓ 4 callers
Function
brent
Pollard rho with brent optimizations taken from: https://gist.github.com/ssanin82/18582bf4a1849dfb8afd
src/RsaCtfTool/lib/algos.py:42
↓ 4 callers
Function
contfrac_to_rational
Contfrac_to_rational implementation
src/RsaCtfTool/lib/number_theory.py:601
↓ 4 callers
Function
cuberoot
(n)
src/RsaCtfTool/lib/number_theory.py:461
↓ 4 callers
Function
fermat
(n)
src/RsaCtfTool/lib/algos.py:494
↓ 4 callers
Function
get_base64_value
Parse input (hex or numerical)
src/RsaCtfTool/lib/utils.py:28
↓ 4 callers
Function
ilogb
greatest integer l such that b**l < = x.
src/RsaCtfTool/lib/number_theory.py:276
↓ 4 callers
Function
n2s
Number to string.
src/RsaCtfTool/lib/utils.py:218
↓ 4 callers
Function
phi
Euler totient φ(n). Computed from the prime factorisation of n via: φ(n) = n ∏_{p|n} (1 − 1/p). The `factors` argument must contain ever
src/RsaCtfTool/lib/number_theory.py:518
↓ 4 callers
Function
prime_base_collision
Prime-base square-collision factoring. Iterates i from ⌊√n⌋ upward computing i² mod n. When i² ≡ p² (mod n) for the current prime p, returns
src/RsaCtfTool/lib/algos.py:140
↓ 4 callers
Function
strong_pseudoprime
Find a factor of N using the strong pseudoprime (Miller-Rabin) test. Iterates prime bases a, climbs the ladder a^f, a^{2f}, a^{4f}, ..., a^{N-1},
src/RsaCtfTool/lib/algos.py:78
↓ 4 callers
Function
trivial_factorization_with_n_phi
(n, phi)
src/RsaCtfTool/lib/number_theory.py:485
↓ 3 callers
Function
A135481
(n)
src/RsaCtfTool/lib/number_theory.py:55
↓ 3 callers
Function
SQUFOF
Code borrowed and adapted from the wikipedia: https://en.wikipedia.org/wiki/Shanks%27s_square_forms_factorization It may contain bugs
src/RsaCtfTool/lib/algos.py:844
↓ 3 callers
Function
_fermat_prime_criterion
Fermat's prime criterion Returns False if n is definitely composite, True if possible prime.
src/RsaCtfTool/lib/number_theory.py:211
↓ 3 callers
Function
_isqrt
(n)
src/RsaCtfTool/lib/number_theory.py:93
↓ 3 callers
Function
_try_smooth_dependency
Try each null-space vector for a nontrivial split x² ≡ y² (mod n). Returns (p, q) on success, None if every dependency gives x ≡ ±y.
src/RsaCtfTool/lib/algos.py:225
↓ 3 callers
Method
can_run
Test if everything is ok for running attack
src/RsaCtfTool/attacks/abstract_attack.py:26
↓ 3 callers
Function
chinese_remainder
(m, a)
src/RsaCtfTool/lib/number_theory.py:536
↓ 3 callers
Function
find_period
(n)
src/RsaCtfTool/lib/number_theory.py:662
↓ 3 callers
Function
generate_pq_from_n_and_p_or_q
Return p and q from (n, p) or (n, q)
src/RsaCtfTool/lib/keys_wrapper.py:43
↓ 3 callers
Method
get_n_mod_d
(self, n, d, use="mersenne")
src/RsaCtfTool/lib/algos.py:566
↓ 3 callers
Function
getpubkeysz
(n)
src/RsaCtfTool/lib/number_theory.py:75
↓ 3 callers
Function
is_roca_vulnerable
(modulus)
src/RsaCtfTool/lib/is_roca_test.py:495
↓ 3 callers
Method
load_attacks
Dynamic load attacks according to context (single key or multiple keys)
src/RsaCtfTool/lib/rsa_attack.py:141
↓ 3 callers
Function
neg_pow
Calculates a^{b} mod n when b is negative
src/RsaCtfTool/lib/number_theory.py:489
↓ 3 callers
Function
pollard_rho
(n)
src/RsaCtfTool/lib/algos.py:812
↓ 3 callers
Method
pre_attack_check
Basic pre Attack checks implementation
src/RsaCtfTool/lib/rsa_attack.py:96
↓ 3 callers
Function
print_results
Print results to output
src/RsaCtfTool/lib/utils.py:138
↓ 3 callers
Function
trivial_factorization_with_n_b
(n, b)
src/RsaCtfTool/lib/number_theory.py:465
↓ 2 callers
Function
FactorHighAndLowBitsEqual
Code taken and heavy modified from https://github.com/google/paranoid_crypto/blob/main/paranoid_crypto/lib/rsa_util.py Licensed under open so
src/RsaCtfTool/lib/algos.py:522
↓ 2 callers
Function
_collect_dixon_relations
Collect B-smooth relations a² ≡ ∏ pⱼ^{eⱼ} (mod n). Returns (relations, split) where *split* is (p, q) if an immediate factor was found (a² ≡
src/RsaCtfTool/lib/algos.py:160
↓ 2 callers
Method
_compute_phi
(self)
src/RsaCtfTool/lib/keys_wrapper.py:97
↓ 2 callers
Function
_make_rsa_key
Return (n, PrivateKey) for the given p, q, e.
tests/test_regression.py:73
↓ 2 callers
Function
a
(n)
src/RsaCtfTool/attacks/single_key/multiple_base_inversion_gcd.py:8
↓ 2 callers
Method
attack
Use sage's internal quadratic sieve method. If input is less than 40 digits, i'll fallback to sage factor method.
src/RsaCtfTool/attacks/single_key/qs.py:16
↓ 2 callers
Function
b
(n)
src/RsaCtfTool/attacks/single_key/multiple_base_inversion_gcd.py:12
↓ 2 callers
Function
c
(n)
src/RsaCtfTool/attacks/single_key/multiple_base_inversion_gcd.py:16
↓ 2 callers
Method
can_stop_tests
Return a boolean if requested actions are done avoiding running extra attacks
src/RsaCtfTool/lib/rsa_attack.py:40
↓ 2 callers
Function
common_modulus_related_message
e1 --> Public Key exponent used to encrypt message m and get ciphertext c1 e2 --> Public Key exponent used to encrypt message m and get ciphe
src/RsaCtfTool/lib/number_theory.py:499
↓ 2 callers
Function
convergents_from_contfrac
Convergents_from_contfrac implementation
src/RsaCtfTool/lib/number_theory.py:613
↓ 2 callers
Function
d
(n)
src/RsaCtfTool/attacks/single_key/multiple_base_inversion_gcd.py:20
↓ 2 callers
Function
euler
Euler's factorisation method. Finds two distinct representations of n as a sum of two squares, then recovers factors via GCD of the mixed sums
src/RsaCtfTool/lib/algos.py:403
↓ 2 callers
Function
factor_2PN
based on: https://github.com/hirogwa/crypto-playground/blob/master/break_rsa.py premise: P is prime > 2 and sqrt(2PN) is close to (Pp + 2q)/2
src/RsaCtfTool/lib/algos.py:437
↓ 2 callers
Function
factor_XYXZ
Factor n of the form x^y · x^z = x^{y+z} where x is prime. Uses integer root extraction: for each exponent k ≥ 2, compute the k-th root r = fl
src/RsaCtfTool/lib/algos.py:482
↓ 2 callers
Method
factorization
(self, N, min_accept, xdiff)
src/RsaCtfTool/lib/algos.py:631
↓ 2 callers
Method
get_boolean_results
Return a boolean value according to requested actions (private, decrypt) if actions are done or not
src/RsaCtfTool/lib/rsa_attack.py:31
↓ 2 callers
Function
hart
Hart's one line attack taken from wagstaff the joy of factoring
src/RsaCtfTool/lib/algos.py:637
↓ 2 callers
Function
inv_mod_pow_of_2
its orders of magnitude faster than invert(a, 2^k) code borrowed from: https://algassert.com/post/1709
src/RsaCtfTool/lib/number_theory.py:618
↓ 2 callers
Function
is_cube
(n)
src/RsaCtfTool/lib/number_theory.py:574
↓ 2 callers
Function
is_lucas
True if n is a Lucas number (A000032).
src/RsaCtfTool/lib/number_theory.py:644
↓ 2 callers
Function
is_pow2
(n)
src/RsaCtfTool/lib/number_theory.py:81
↓ 2 callers
Function
kraitchik
(n)
src/RsaCtfTool/lib/algos.py:653
↓ 2 callers
Function
lehman
based on: https://programmingpraxis.com/2017/08/22/lehmans-factoring-algorithm/
src/RsaCtfTool/lib/algos.py:668
↓ 2 callers
Function
lehmer_machine
fermat based integer factorization
src/RsaCtfTool/lib/algos.py:691
↓ 2 callers
Function
main
()
src/RsaCtfTool/main.py:578
↓ 2 callers
Function
mlucas
Helper function for williams_pp1(). Multiplies along a Lucas sequence modulo n.
src/RsaCtfTool/lib/number_theory.py:631
↓ 2 callers
Function
pollard_P_1
Pollard P1 implementation
src/RsaCtfTool/lib/algos.py:793
↓ 2 callers
Function
pollard_strassen
https://math.stackexchange.com/questions/185524/pollard-strassen-algorithm
src/RsaCtfTool/lib/algos.py:909
↓ 2 callers
Function
print_decrypted_res
(c, logger)
src/RsaCtfTool/lib/utils.py:39
↓ 2 callers
Method
print_results_details
Print extra output according to requested action. Decrypt data if needed.
src/RsaCtfTool/lib/rsa_attack.py:58
↓ 2 callers
Method
priv_key_send2fdb
(self)
src/RsaCtfTool/lib/rsa_attack.py:183
↓ 2 callers
Function
send2fdb
(composite, factors)
src/RsaCtfTool/lib/fdb.py:11
↓ 2 callers
Function
terminate_proc_tree
(pid, including_parent=False)
src/RsaCtfTool/lib/utils.py:244
↓ 2 callers
Function
tonelli
Tonelli-Shanks modular squareroot algorithm
src/RsaCtfTool/lib/number_theory.py:545
↓ 2 callers
Function
wiener
(n, e, progress=True)
src/RsaCtfTool/lib/algos.py:924
↓ 2 callers
Function
williams_pp1
(n)
src/RsaCtfTool/lib/algos.py:942
↓ 1 callers
Function
A000265
(n)
src/RsaCtfTool/lib/number_theory.py:59
↓ 1 callers
Function
FF
(n)
src/RsaCtfTool/attacks/single_key/multiple_base_inversion_gcd.py:24
↓ 1 callers
Function
InverseInverseSqrt2exp
Computes an approximation to the modular inverse square root of `n` with `k` bits.
src/RsaCtfTool/lib/algos.py:509
↓ 1 callers
Method
_attack_test_mode
(self, attacks_list)
src/RsaCtfTool/lib/rsa_attack.py:248
↓ 1 callers
Method
_compute_d
(self, e)
src/RsaCtfTool/lib/keys_wrapper.py:104
↓ 1 callers
Function
_compute_missing_values
(args, logger)
src/RsaCtfTool/main.py:475
↓ 1 callers
Function
_compute_n_from_pq
(args)
src/RsaCtfTool/main.py:451
↓ 1 callers
Function
_compute_other_prime
(args)
src/RsaCtfTool/main.py:470
↓ 1 callers
Method
_construct_key_from_components
(self)
src/RsaCtfTool/lib/keys_wrapper.py:113
↓ 1 callers
Method
_execute_single_attack
(self, attack_module)
src/RsaCtfTool/lib/rsa_attack.py:308
↓ 1 callers
Method
_fib_res
fibonacci sequence nth item modulo p
src/RsaCtfTool/lib/algos.py:557
↓ 1 callers
Function
_gcd
(a, b)
src/RsaCtfTool/lib/number_theory.py:107
next →
1–100 of 614, ranked by callers