Beispiel #1
0
        public LucKeyGenerator(LucPrime prime, BigInteger message)
        {
            P            = message;
            PrimeNumbers = prime;
            if (PrimeNumbers.N <= message)
            {
                throw new ArgumentException("N need to be greater than message");
            }
            PublicKey = new LucPublicKey(GenerateSimpleE(), PrimeNumbers.N);

            PrivateKey = new LucPrivateKey(getSmalld(PublicKey), PrimeNumbers.N);
        }
Beispiel #2
0
        private BigInteger GetGCDPublicKey(LucPrime lucPrimeNumbers)
        {
            Random     r = new Random();
            BigInteger e = 0;
            BigInteger t = BigInteger.Multiply(lucPrimeNumbers.P - 1, lucPrimeNumbers.Q - 1) * BigInteger.Multiply(lucPrimeNumbers.P + 1, lucPrimeNumbers.Q + 1);

            do
            {
                e = r.Next(MinKeyValue, MaxKeyValue);
            } while (BigInteger.GreatestCommonDivisor(e, t) != 1);

            return(e);
        }
 /// <summary>
 /// calculate nambers of Legand
 /// </summary>
 /// <param name="primeNumbers">Structure contains two prime numbers</param>
 /// <param name="message">open text  which need to encrypt</param>
 public LegendreNumbers(LucPrime primeNumbers, BigInteger message) : this(message : message, q : primeNumbers.Q, p : primeNumbers.P)
 {
 }
Beispiel #4
0
 public LucPublicKey(LucPrime lucPrimeNumbers, int size) : this(size)
 {
     N = lucPrimeNumbers.N;
     e = GetGCDPublicKey(lucPrimeNumbers);
 }
Beispiel #5
0
 public LucPublicKey(LucPrime lucPrimeNumbers) : this((int)defaultSize)
 {
     N = lucPrimeNumbers.N;
     e = GetGCDPublicKey(lucPrimeNumbers);
 }