• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java KeyAgreementException类的典型用法和代码示例

java 3次浏览

本文整理汇总了Java中gnu.javax.crypto.key.KeyAgreementException的典型用法代码示例。如果您正苦于以下问题:Java KeyAgreementException类的具体用法?Java KeyAgreementException怎么用?Java KeyAgreementException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

KeyAgreementException类属于gnu.javax.crypto.key包,在下文中一共展示了KeyAgreementException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: engineInit

点赞 3

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
protected void engineInit(final Map attributes) throws KeyAgreementException
{
  rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
  N = (BigInteger) attributes.get(SHARED_MODULUS);
  if (N == null)
    throw new KeyAgreementException("missing shared modulus");
  g = (BigInteger) attributes.get(GENERATOR);
  if (g == null)
    throw new KeyAgreementException("missing generator");
  final String md = (String) attributes.get(HASH_FUNCTION);
  if (md == null || md.trim().length() == 0)
    throw new KeyAgreementException("missing hash function");
  srp = SRP.instance(md);
  I = (String) attributes.get(USER_IDENTITY);
  if (I == null)
    throw new KeyAgreementException("missing user identity");
  p = (byte[]) attributes.get(USER_PASSWORD);
  if (p == null)
    throw new KeyAgreementException("missing user password");
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:21,
代码来源:SRP6User.java

示例2: sendIdentity

点赞 3

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
private OutgoingMessage sendIdentity(final IncomingMessage in)
    throws KeyAgreementException
{
  // generate an ephemeral keypair
  final SRPKeyPairGenerator kpg = new SRPKeyPairGenerator();
  final Map attributes = new HashMap();
  if (rnd != null)
    attributes.put(SRPKeyPairGenerator.SOURCE_OF_RANDOMNESS, rnd);
  attributes.put(SRPKeyPairGenerator.SHARED_MODULUS, N);
  attributes.put(SRPKeyPairGenerator.GENERATOR, g);
  kpg.setup(attributes);
  userKeyPair = kpg.generate();
  final OutgoingMessage result = new OutgoingMessage();
  result.writeString(I);
  result.writeMPI(((SRPPublicKey) userKeyPair.getPublic()).getY());
  return result;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:18,
代码来源:SRP6User.java

示例3: engineInit

点赞 3

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
protected void engineInit(final Map attributes) throws KeyAgreementException
{
  rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
  N = (BigInteger) attributes.get(SHARED_MODULUS);
  if (N == null)
    throw new KeyAgreementException("missing shared modulus");
  g = (BigInteger) attributes.get(GENERATOR);
  if (g == null)
    throw new KeyAgreementException("missing generator");
  final String md = (String) attributes.get(HASH_FUNCTION);
  if (md == null || md.trim().length() == 0)
    throw new KeyAgreementException("missing hash function");
  srp = SRP.instance(md);
  passwordDB = (SRPAuthInfoProvider) attributes.get(HOST_PASSWORD_DB);
  if (passwordDB == null)
    throw new KeyAgreementException("missing SRP password database");
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:18,
代码来源:SRP6Host.java

示例4: computeSharedSecret

点赞 3

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
private OutgoingMessage computeSharedSecret(IncomingMessage in)
    throws KeyAgreementException
{
  BigInteger p = B.getParams().getP();
  BigInteger g = B.getParams().getG();
  BigInteger yb = B.getY();
  // A chooses a random integer x, 1 <= x <= p-2
  // rfc-2631 restricts x to only be in [2, p-1]
  BigInteger p_minus_2 = p.subtract(TWO);
  byte[] xBytes = new byte[(p_minus_2.bitLength() + 7) / 8];
  BigInteger x;
  do
    {
      nextRandomBytes(xBytes);
      x = new BigInteger(1, xBytes);
    }
  while (x.compareTo(TWO) >= 0 && x.compareTo(p_minus_2) <= 0);
  // A sends B the message: g^x mod p
  OutgoingMessage result = new OutgoingMessage();
  result.writeMPI(g.modPow(x, p));
  // A computes the key as K = (yb)^x mod p
  ZZ = yb.modPow(x, p); // ZZ = (yb ^ xa) mod p
  complete = true;
  return result;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:26,
代码来源:ElGamalSender.java

示例5: sendRandomSecret

点赞 3

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
private OutgoingMessage sendRandomSecret(IncomingMessage in)
    throws KeyAgreementException
{
  BigInteger p = ownerKey.getParams().getP();
  BigInteger g = ownerKey.getParams().getG();
  // A chooses a random integer x, 1 <= x <= p-2
  // rfc-2631 restricts x to only be in [2, p-1]
  BigInteger p_minus_2 = p.subtract(TWO);
  byte[] xBytes = new byte[(p_minus_2.bitLength() + 7) / 8];
  do
    {
      nextRandomBytes(xBytes);
      x = new BigInteger(1, xBytes);
    }
  while (! (x.compareTo(TWO) >= 0 && x.compareTo(p_minus_2) <= 0));
  // A sends B the message: g^x mod p
  OutgoingMessage result = new OutgoingMessage();
  result.writeMPI(g.modPow(x, p));
  return result;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:21,
代码来源:DiffieHellmanSender.java

示例6: computeSharedSecret

点赞 3

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
private OutgoingMessage computeSharedSecret(IncomingMessage in)
    throws KeyAgreementException
{
  BigInteger m1 = in.readMPI();
  if (m1 == null)
    throw new KeyAgreementException("missing message (1)");
  BigInteger p = ownerKey.getParams().getP();
  BigInteger g = ownerKey.getParams().getG();
  // B chooses a random integer y, 1 <= y <= p-2
  // rfc-2631 restricts y to only be in [2, p-1]
  BigInteger p_minus_2 = p.subtract(TWO);
  byte[] xBytes = new byte[(p_minus_2.bitLength() + 7) / 8];
  do
    {
      nextRandomBytes(xBytes);
      y = new BigInteger(1, xBytes);
    }
  while (! (y.compareTo(TWO) >= 0 && y.compareTo(p_minus_2) <= 0));
  ZZ = m1.modPow(y, p); // ZZ = (yb ^ xa) mod p
  complete = true;
  // B sends A the message: g^y mod p
  OutgoingMessage result = new OutgoingMessage();
  result.writeMPI(g.modPow(y, p)); // message (2)
  return result;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:26,
代码来源:DiffieHellmanReceiver.java

示例7: computeSharedSecret

点赞 2

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
protected OutgoingMessage computeSharedSecret(final IncomingMessage in)
    throws KeyAgreementException
{
  super.computeSharedSecret(in);
  final byte[] sBytes = Util.trim(K);
  final IMessageDigest hash = srp.newDigest();
  hash.update(sBytes, 0, sBytes.length);
  K = new BigInteger(1, hash.digest());
  return null;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:11,
代码来源:SRP6SaslServer.java

示例8: engineInit

点赞 2

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
protected void engineInit(final Map attributes) throws KeyAgreementException
{
  rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
  final String md = (String) attributes.get(HASH_FUNCTION);
  if (md == null || md.trim().length() == 0)
    throw new KeyAgreementException("missing hash function");
  srp = SRP.instance(md);
  passwordDB = (SRPAuthInfoProvider) attributes.get(HOST_PASSWORD_DB);
  if (passwordDB == null)
    throw new KeyAgreementException("missing SRP password database");
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:12,
代码来源:SRP6TLSServer.java

示例9: engineProcessMessage

点赞 2

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
protected OutgoingMessage engineProcessMessage(final IncomingMessage in)
    throws KeyAgreementException
{
  switch (step)
    {
    case 0:
      return sendParameters(in);
    case 1:
      return computeSharedSecret(in);
    default:
      throw new IllegalStateException("unexpected state");
    }
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:14,
代码来源:SRP6TLSServer.java

示例10: computeSharedSecret

点赞 2

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
protected OutgoingMessage computeSharedSecret(final IncomingMessage in)
    throws KeyAgreementException
{
  final BigInteger A = in.readMPI();
  final BigInteger B = ((SRPPublicKey) hostKeyPair.getPublic()).getY();
  final BigInteger u = uValue(A, B); // u = H(A | B)
  // compute S = (Av^u) ^ b
  final BigInteger b = ((SRPPrivateKey) hostKeyPair.getPrivate()).getX();
  final BigInteger v = ((SRPPrivateKey) hostKeyPair.getPrivate()).getV();
  final BigInteger S = A.multiply(v.modPow(u, N)).modPow(b, N);
  K = S;
  complete = true;
  return null;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:15,
代码来源:SRP6TLSServer.java

示例11: engineInit

点赞 2

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
protected void engineInit(final Map attributes) throws KeyAgreementException
{
  rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
  final String md = (String) attributes.get(HASH_FUNCTION);
  if (md == null || md.trim().length() == 0)
    throw new KeyAgreementException("missing hash function");
  srp = SRP.instance(md);
  I = (String) attributes.get(USER_IDENTITY);
  if (I == null)
    throw new KeyAgreementException("missing user identity");
  p = (byte[]) attributes.get(USER_PASSWORD);
  if (p == null)
    throw new KeyAgreementException("missing user password");
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:15,
代码来源:SRP6TLSClient.java

示例12: engineProcessMessage

点赞 2

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
protected OutgoingMessage engineProcessMessage(final IncomingMessage in)
    throws KeyAgreementException
{
  switch (step)
    {
    case 0:
      return sendIdentity(in);
    case 1:
      return computeSharedSecret(in);
    default:
      throw new IllegalStateException("unexpected state");
    }
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:14,
代码来源:SRP6TLSClient.java

示例13: sendIdentity

点赞 2

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
private OutgoingMessage sendIdentity(final IncomingMessage in)
    throws KeyAgreementException
{
  final OutgoingMessage result = new OutgoingMessage();
  result.writeString(I);
  return result;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:8,
代码来源:SRP6TLSClient.java

示例14: computeSharedSecret

点赞 2

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
protected OutgoingMessage computeSharedSecret(final IncomingMessage in)
    throws KeyAgreementException
{
  N = in.readMPI();
  g = in.readMPI();
  final BigInteger s = in.readMPI();
  final BigInteger B = in.readMPI();
  // generate an ephemeral keypair
  final SRPKeyPairGenerator kpg = new SRPKeyPairGenerator();
  final Map attributes = new HashMap();
  if (rnd != null)
    attributes.put(SRPKeyPairGenerator.SOURCE_OF_RANDOMNESS, rnd);
  attributes.put(SRPKeyPairGenerator.SHARED_MODULUS, N);
  attributes.put(SRPKeyPairGenerator.GENERATOR, g);
  kpg.setup(attributes);
  userKeyPair = kpg.generate();
  final BigInteger A = ((SRPPublicKey) userKeyPair.getPublic()).getY();
  final BigInteger u = uValue(A, B); // u = H(A | B)
  final BigInteger x;
  try
    {
      x = new BigInteger(1, srp.computeX(Util.trim(s), I, p));
    }
  catch (Exception e)
    {
      throw new KeyAgreementException("computeSharedSecret()", e);
    }
  // compute S = (B - 3g^x) ^ (a + ux)
  final BigInteger a = ((SRPPrivateKey) userKeyPair.getPrivate()).getX();
  final BigInteger S = B.subtract(THREE.multiply(g.modPow(x, N)))
                        .modPow(a.add(u.multiply(x)), N);
  K = S;
  final OutgoingMessage result = new OutgoingMessage();
  result.writeMPI(A);
  complete = true;
  return result;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:38,
代码来源:SRP6TLSClient.java

示例15: computeSharedSecret

点赞 2

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
private OutgoingMessage computeSharedSecret(final IncomingMessage in)
    throws KeyAgreementException
{
  final BigInteger s = in.readMPI();
  final BigInteger B = in.readMPI();
  final BigInteger A = ((SRPPublicKey) userKeyPair.getPublic()).getY();
  final BigInteger u = uValue(A, B); // u = H(A | B)
  final BigInteger x;
  try
    {
      x = new BigInteger(1, srp.computeX(Util.trim(s), I, p));
    }
  catch (Exception e)
    {
      throw new KeyAgreementException("computeSharedSecret()", e);
    }
  // compute S = (B - 3g^x) ^ (a + ux)
  final BigInteger a = ((SRPPrivateKey) userKeyPair.getPrivate()).getX();
  final BigInteger S = B.subtract(THREE.multiply(g.modPow(x, N)))
                        .modPow(a.add(u.multiply(x)), N);
  final byte[] sBytes = Util.trim(S);
  final IMessageDigest hash = srp.newDigest();
  hash.update(sBytes, 0, sBytes.length);
  K = new BigInteger(1, hash.digest());
  complete = true;
  return null;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:28,
代码来源:SRP6User.java

示例16: computeSharedSecret

点赞 2

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
protected OutgoingMessage computeSharedSecret(final IncomingMessage in)
    throws KeyAgreementException
{
  final OutgoingMessage result = super.computeSharedSecret(in);
  final byte[] sBytes = Util.trim(K);
  final IMessageDigest hash = srp.newDigest();
  hash.update(sBytes, 0, sBytes.length);
  K = new BigInteger(1, hash.digest());
  return result;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:11,
代码来源:SRP6SaslClient.java

示例17: engineProcessMessage

点赞 2

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
protected OutgoingMessage engineProcessMessage(final IncomingMessage in)
    throws KeyAgreementException
{
  switch (step)
    {
    case 0:
      return computeSharedSecret(in);
    default:
      throw new IllegalStateException("unexpected state");
    }
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:12,
代码来源:SRP6Host.java

示例18: engineInit

点赞 2

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
protected void engineInit(Map attributes) throws KeyAgreementException
{
  rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
  // One-time setup (key generation and publication). Each user B generates
  // a keypair and publishes its public key
  B = (DHPublicKey) attributes.get(KA_ELGAMAL_RECIPIENT_PUBLIC_KEY);
  if (B == null)
    throw new KeyAgreementException("missing recipient public key");
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:10,
代码来源:ElGamalSender.java

示例19: engineProcessMessage

点赞 2

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
protected OutgoingMessage engineProcessMessage(IncomingMessage in)
    throws KeyAgreementException
{
  switch (step)
    {
    case 0:
      return computeSharedSecret(in);
    default:
      throw new IllegalStateException("unexpected state");
    }
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:12,
代码来源:ElGamalSender.java

示例20: engineInit

点赞 2

import gnu.javax.crypto.key.KeyAgreementException; //导入依赖的package包/类
protected void engineInit(Map attributes) throws KeyAgreementException
{
  rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
  // One-time setup (key generation and publication). Each user B generates
  // a keypair and publishes its public key
  B = (DHPrivateKey) attributes.get(KA_ELGAMAL_RECIPIENT_PRIVATE_KEY);
  if (B == null)
    throw new KeyAgreementException("missing recipient private key");
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:10,
代码来源:ElGamalReceiver.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)