org.metasyntactic.security
Class RivestShamirAdleman

java.lang.Object
  |
  +--org.metasyntactic.security.RivestShamirAdleman

public class RivestShamirAdleman
extends java.lang.Object


Method Summary
static java.util.List chunkString(java.lang.String s, java.math.BigInteger n)
           
static java.lang.String decrypt(org.metasyntactic.security.RivestShamirAdleman.PrivateKey privateKey, java.lang.String M)
           
static java.lang.String encrypt(org.metasyntactic.security.RivestShamirAdleman.PublicKey publicKey, java.lang.String M)
           
static void encryptInput(int numPrimes, java.lang.String M)
           
static java.math.BigInteger[] extendedEuclideanAlgorithm(java.math.BigInteger a, java.math.BigInteger b)
          Input: positive integers a and b Output: integers x and y such that gcd(a, b) = xa + yb
static java.math.BigInteger gcd(java.math.BigInteger a, java.math.BigInteger b)
           
static java.math.BigInteger greatestCommonDivisor(java.math.BigInteger a, java.math.BigInteger b)
           
static java.math.BigInteger inverse(java.math.BigInteger a, java.math.BigInteger m)
          Given a and m, we know that gcd(a, m) = a*x + m*y.
static org.metasyntactic.security.RivestShamirAdleman.KeyPair keyPairGenerator(java.util.Collection primes)
           
static org.metasyntactic.security.RivestShamirAdleman.KeyPair keyPairGenerator(int numPrimes)
           
static void main(java.lang.String[] args)
           
static java.math.BigInteger n(java.util.Collection primes)
          Returns the product of the elements of primes
static java.math.BigInteger powerMod(java.math.BigInteger base, java.math.BigInteger exponent, java.math.BigInteger modulus)
           
static java.math.BigInteger powerModulus(java.math.BigInteger base, java.math.BigInteger exponent, java.math.BigInteger modulus)
          Returns (base ^ exponent) % modulus
static java.util.Set randomPrimes(int k)
           
static java.util.Set randomPrimes(int k, int certainty)
           
static java.util.Set randomPrimes(int k, int certainty, int bits)
          Creates a set of k distinct primes.
static java.math.BigInteger randomRelativePrime(java.math.BigInteger t)
           
static java.math.BigInteger randomRelativePrime(java.math.BigInteger t, int bits)
           
static java.math.BigInteger randomRelPrime(java.math.BigInteger t)
           
static java.math.BigInteger totient(java.util.Collection primes)
          When n is a positive integer, Euler's totient function, , is defined to be the number of positive integers not greater than n and relatively prime to n
static java.lang.String unchunkString(java.util.List chunks)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

randomPrimes

public static java.util.Set randomPrimes(int k)

randomPrimes

public static java.util.Set randomPrimes(int k,
                                         int certainty)

randomPrimes

public static java.util.Set randomPrimes(int k,
                                         int certainty,
                                         int bits)
Creates a set of k distinct primes. Each prime is between 2**1 and 2**bits length, each with a certainty of (1 - (1/2)**certainty) that the number is prime


n

public static java.math.BigInteger n(java.util.Collection primes)
Returns the product of the elements of primes

Parameters:
primes - A collection of BigIntegers
Returns:
The product of all the values in primes

totient

public static java.math.BigInteger totient(java.util.Collection primes)
When n is a positive integer, Euler's totient function, , is defined to be the number of positive integers not greater than n and relatively prime to n


gcd

public static java.math.BigInteger gcd(java.math.BigInteger a,
                                       java.math.BigInteger b)

greatestCommonDivisor

public static java.math.BigInteger greatestCommonDivisor(java.math.BigInteger a,
                                                         java.math.BigInteger b)

randomRelPrime

public static java.math.BigInteger randomRelPrime(java.math.BigInteger t)

randomRelativePrime

public static java.math.BigInteger randomRelativePrime(java.math.BigInteger t)

randomRelativePrime

public static java.math.BigInteger randomRelativePrime(java.math.BigInteger t,
                                                       int bits)

powerMod

public static java.math.BigInteger powerMod(java.math.BigInteger base,
                                            java.math.BigInteger exponent,
                                            java.math.BigInteger modulus)

powerModulus

public static java.math.BigInteger powerModulus(java.math.BigInteger base,
                                                java.math.BigInteger exponent,
                                                java.math.BigInteger modulus)
Returns (base ^ exponent) % modulus


inverse

public static java.math.BigInteger inverse(java.math.BigInteger a,
                                           java.math.BigInteger m)
Given a and m, we know that gcd(a, m) = a*x + m*y. The inverse of a mod m is defined simply as being x in the bazoot representation of the gcd


extendedEuclideanAlgorithm

public static java.math.BigInteger[] extendedEuclideanAlgorithm(java.math.BigInteger a,
                                                                java.math.BigInteger b)
Input: positive integers a and b Output: integers x and y such that gcd(a, b) = xa + yb


chunkString

public static java.util.List chunkString(java.lang.String s,
                                         java.math.BigInteger n)

unchunkString

public static java.lang.String unchunkString(java.util.List chunks)

encrypt

public static java.lang.String encrypt(org.metasyntactic.security.RivestShamirAdleman.PublicKey publicKey,
                                       java.lang.String M)

decrypt

public static java.lang.String decrypt(org.metasyntactic.security.RivestShamirAdleman.PrivateKey privateKey,
                                       java.lang.String M)

keyPairGenerator

public static org.metasyntactic.security.RivestShamirAdleman.KeyPair keyPairGenerator(int numPrimes)

keyPairGenerator

public static org.metasyntactic.security.RivestShamirAdleman.KeyPair keyPairGenerator(java.util.Collection primes)

encryptInput

public static void encryptInput(int numPrimes,
                                java.lang.String M)

main

public static void main(java.lang.String[] args)