Ejemplo n.º 1
0
        public static ECKeyPair generateKeyPair()
        {
            Curve25519KeyPair keyPair = Curve25519.getInstance(BEST).generateKeyPair();

            return(new ECKeyPair(new DjbECPublicKey(keyPair.getPublicKey()),
                                 new DjbECPrivateKey(keyPair.getPrivateKey())));
        }
Ejemplo n.º 2
0
 public static Curve25519 getInstance(int test)
 {
     if (instance == null)
     {
         instance = new Curve25519();
     }
     return instance;
 }
Ejemplo n.º 3
0
 public static Curve25519 getInstance(int test)
 {
     if (instance == null)
     {
         instance = new Curve25519();
     }
     return(instance);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Accesses the currently in use Curve25519 provider, according to the type requested.
 /// </summary>
 /// <param name="type">Type of provider requested.</param>
 /// <returns>Provider</returns>
 public static Curve25519 getInstance(Curve25519ProviderType type)
 {
     if (instance == null)
     {
         instance          = new Curve25519();
         instance.provider = (ICurve25519Provider) new Curve25519NativeProvider();
     }
     return(instance);
 }
Ejemplo n.º 5
0
		/// <summary>
		/// Accesses the currently in use Curve25519 provider, according to the type requested.
		/// </summary>
		/// <param name="type">Type of provider requested.</param>
		/// <returns>Provider</returns>
		public static Curve25519 getInstance(Curve25519ProviderType type)
		{
			if (instance == null)
			{
				instance = new Curve25519();
				instance.provider = (ICurve25519Provider)new Curve25519NativeProvider();
			}
			return instance;
		}
Ejemplo n.º 6
0
 public static byte[] calculateSignature(ECPrivateKey signingKey, byte[] message)
 {
     if (signingKey.getType() == DJB_TYPE)
     {
         return(Curve25519.getInstance(BEST)
                .calculateSignature(((DjbECPrivateKey)signingKey).getPrivateKey(), message));
     }
     else
     {
         throw new InvalidKeyException("Unknown type: " + signingKey.getType());
     }
 }
Ejemplo n.º 7
0
 public static bool verifySignature(ECPublicKey signingKey, byte[] message, byte[] signature)
 {
     if (signingKey.getType() == DJB_TYPE)
     {
         return(Curve25519.getInstance(BEST)
                .verifySignature(((DjbECPublicKey)signingKey).getPublicKey(), message, signature));
     }
     else
     {
         throw new InvalidKeyException("Unknown type: " + signingKey.getType());
     }
 }
Ejemplo n.º 8
0
        public static byte[] calculateAgreement(ECPublicKey publicKey, ECPrivateKey privateKey)
        {
            if (publicKey.getType() != privateKey.getType())
            {
                throw new InvalidKeyException("Public and private keys must be of the same type!");
            }

            if (publicKey.getType() == DJB_TYPE)
            {
                return(Curve25519.getInstance(BEST)
                       .calculateAgreement(((DjbECPublicKey)publicKey).getPublicKey(),
                                           ((DjbECPrivateKey)privateKey).getPrivateKey()));
            }
            else
            {
                throw new InvalidKeyException("Unknown type: " + publicKey.getType());
            }
        }
Ejemplo n.º 9
0
 public static bool isNative()
 {
     return(Curve25519.getInstance(BEST).isNative());
 }
Ejemplo n.º 10
0
 public static bool isNative()
 {
     return(Curve25519.getInstance(Curve25519ProviderType.BEST).isNative());
 }