You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
1.5 KiB
86 lines
1.5 KiB
8 months ago
|
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||
|
#pragma warning disable
|
||
|
using System;
|
||
|
|
||
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Math;
|
||
|
|
||
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters
|
||
|
{
|
||
|
public class ElGamalParameters
|
||
|
: ICipherParameters
|
||
|
{
|
||
|
private readonly BigInteger p, g;
|
||
|
private readonly int l;
|
||
|
|
||
|
public ElGamalParameters(
|
||
|
BigInteger p,
|
||
|
BigInteger g)
|
||
|
: this(p, g, 0)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public ElGamalParameters(
|
||
|
BigInteger p,
|
||
|
BigInteger g,
|
||
|
int l)
|
||
|
{
|
||
|
if (p == null)
|
||
|
throw new ArgumentNullException("p");
|
||
|
if (g == null)
|
||
|
throw new ArgumentNullException("g");
|
||
|
|
||
|
this.p = p;
|
||
|
this.g = g;
|
||
|
this.l = l;
|
||
|
}
|
||
|
|
||
|
public BigInteger P
|
||
|
{
|
||
|
get { return p; }
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* return the generator - g
|
||
|
*/
|
||
|
public BigInteger G
|
||
|
{
|
||
|
get { return g; }
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* return private value limit - l
|
||
|
*/
|
||
|
public int L
|
||
|
{
|
||
|
get { return l; }
|
||
|
}
|
||
|
|
||
|
public override bool Equals(
|
||
|
object obj)
|
||
|
{
|
||
|
if (obj == this)
|
||
|
return true;
|
||
|
|
||
|
ElGamalParameters other = obj as ElGamalParameters;
|
||
|
|
||
|
if (other == null)
|
||
|
return false;
|
||
|
|
||
|
return Equals(other);
|
||
|
}
|
||
|
|
||
|
protected bool Equals(
|
||
|
ElGamalParameters other)
|
||
|
{
|
||
|
return p.Equals(other.p) && g.Equals(other.g) && l == other.l;
|
||
|
}
|
||
|
|
||
|
public override int GetHashCode()
|
||
|
{
|
||
|
return p.GetHashCode() ^ g.GetHashCode() ^ l;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#pragma warning restore
|
||
|
#endif
|