congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
org.spongycastle.crypto.params
Code IndexAdd Tabnine to your IDE (free)

How to use org.spongycastle.crypto.params

Best Java code snippets using org.spongycastle.crypto.params (Showing top 20 results out of 387)

origin: ethereum/ethereumj

private void extractParams(CipherParameters params)
{
  if (params instanceof ParametersWithIV)
  {
    this.IV = ((ParametersWithIV)params).getIV();
    this.param = (IESParameters)((ParametersWithIV)params).getParameters();
  }
  else
  {
    this.IV = null;
    this.param = (IESParameters)params;
  }
}
origin: ethereum/ethereumj

public void init(DerivationParameters param)
{
  if (param instanceof KDFParameters)
  {
    KDFParameters p = (KDFParameters)param;
    shared = p.getSharedSecret();
    iv = p.getIV();
  }
  else if (param instanceof ISO18033KDFParameters)
  {
    ISO18033KDFParameters p = (ISO18033KDFParameters)param;
    shared = p.getSeed();
    iv = null;
  }
  else
  {
    throw new IllegalArgumentException("KDF parameters required for KDF2Generator");
  }
}
origin: ethereum/ethereumj

public void init(DerivationParameters param) {
  if(!(param instanceof MGFParameters)) {
    throw new IllegalArgumentException("MGF parameters required for MGF1Generator");
  } else {
    MGFParameters p = (MGFParameters)param;
    this.seed = p.getSeed();
  }
}
origin: ethereum/ethereumj

private static EthereumIESEngine makeIESEngine(boolean isEncrypt, ECPoint pub, BigInteger prv, byte[] IV) {
  AESEngine aesFastEngine = new AESEngine();
  EthereumIESEngine iesEngine = new EthereumIESEngine(
      new ECDHBasicAgreement(),
      new ConcatKDFBytesGenerator(new SHA256Digest()),
      new HMac(new SHA256Digest()),
      new SHA256Digest(),
      new BufferedBlockCipher(new SICBlockCipher(aesFastEngine)));
  byte[]         d = new byte[] {};
  byte[]         e = new byte[] {};
  IESParameters p = new IESWithCipherParameters(d, e, KEY_SIZE, KEY_SIZE);
  ParametersWithIV parametersWithIV = new ParametersWithIV(p, IV);
  iesEngine.init(isEncrypt, new ECPrivateKeyParameters(prv, CURVE), new ECPublicKeyParameters(pub, CURVE), parametersWithIV);
  return iesEngine;
}
origin: ethereum/ethereumj

public FrameCodec(EncryptionHandshake.Secrets secrets) {
  this.mac = secrets.mac;
  BlockCipher cipher;
  enc = new SICBlockCipher(cipher = new AESEngine());
  enc.init(true, new ParametersWithIV(new KeyParameter(secrets.aes), new byte[cipher.getBlockSize()]));
  dec = new SICBlockCipher(cipher = new AESEngine());
  dec.init(false, new ParametersWithIV(new KeyParameter(secrets.aes), new byte[cipher.getBlockSize()]));
  egressMac = secrets.egressMac;
  ingressMac = secrets.ingressMac;
}
origin: ethereum/ethereumj

public static byte[] decrypt(BigInteger privKey, byte[] cipher, byte[] macData) throws IOException, InvalidCipherTextException {
  byte[] plaintext;
  ByteArrayInputStream is = new ByteArrayInputStream(cipher);
  byte[] ephemBytes = new byte[2*((CURVE.getCurve().getFieldSize()+7)/8) + 1];
  is.read(ephemBytes);
  ECPoint ephem = CURVE.getCurve().decodePoint(ephemBytes);
  byte[] IV = new byte[KEY_SIZE /8];
  is.read(IV);
  byte[] cipherBody = new byte[is.available()];
  is.read(cipherBody);
  plaintext = decrypt(ephem, privKey, IV, cipherBody, macData);
  return plaintext;
}
origin: ethereum/ethereumj

/**
 * Returns public key bytes from the given private key. To convert a byte array into a BigInteger, use <tt>
 * new BigInteger(1, bytes);</tt>
 *
 * @param privKey -
 * @param compressed -
 * @return -
 */
public static byte[] publicKeyFromPrivate(BigInteger privKey, boolean compressed) {
  ECPoint point = CURVE.getG().multiply(privKey);
  return point.getEncoded(compressed);
}
origin: ethereum/ethereumj

private AESEngine makeMacCipher() {
  // Stateless AES encryption
  AESEngine macc = new AESEngine();
  macc.init(true, new KeyParameter(mac));
  return macc;
}
origin: ethereum/ethereumj

  @Override
  public byte[] getEncoded(AsymmetricKeyParameter asymmetricKeyParameter) {
    return ((ECPublicKeyParameters) asymmetricKeyParameter).getQ().getEncoded(false);
  }
}
origin: ethereum/ethereumj

@BeforeClass
public static void beforeAll() {
  curve = new ECDomainParameters(IES_CURVE_PARAM.getCurve(), IES_CURVE_PARAM.getG(), IES_CURVE_PARAM.getN(), IES_CURVE_PARAM.getH());
}
origin: ethereum/ethereumj

public static byte[] decrypt(ECPoint ephem, BigInteger prv, byte[] IV, byte[] cipher, byte[] macData) throws InvalidCipherTextException {
  AESEngine aesFastEngine = new AESEngine();
  EthereumIESEngine iesEngine = new EthereumIESEngine(
      new ECDHBasicAgreement(),
      new ConcatKDFBytesGenerator(new SHA256Digest()),
      new HMac(new SHA256Digest()),
      new SHA256Digest(),
      new BufferedBlockCipher(new SICBlockCipher(aesFastEngine)));
  byte[]         d = new byte[] {};
  byte[]         e = new byte[] {};
  IESParameters p = new IESWithCipherParameters(d, e, KEY_SIZE, KEY_SIZE);
  ParametersWithIV parametersWithIV =
      new ParametersWithIV(p, IV);
  iesEngine.init(false, new ECPrivateKeyParameters(prv, CURVE), new ECPublicKeyParameters(ephem, CURVE), parametersWithIV);
  return iesEngine.processBlock(cipher, 0, cipher.length, macData);
}
origin: ethereum/ethereumj

/**
 * Utility for decompressing an elliptic curve point. Returns the same point if it's already compressed.
 * See the ECKey class docs for a discussion of point compression.
 *
 * @param compressed -
 *
 * @return  -
 * @deprecated per-point compression property will be removed in Bouncy Castle
 */
public static ECPoint decompressPoint(ECPoint compressed) {
  return CURVE.getCurve().decodePoint(compressed.getEncoded(false));
}
origin: ethereum/ethereumj

/**
 * Creates an ECKey given the private key only.
 *
 * @param privKey -
 *
 *
 * @return  -
 */
public static ECKey fromPrivate(BigInteger privKey) {
  return new ECKey(privKey, CURVE.getG().multiply(privKey));
}
origin: ethereum/ethereumj

  public byte[] getEncoded(AsymmetricKeyParameter keyParameter)
  {
    return ((ECPublicKeyParameters)keyParameter).getQ().getEncoded();
  }
});
origin: ethereum/ethereumj

private static EthereumIESEngine makeIESEngine(boolean isEncrypt, ECPoint pub, BigInteger prv, byte[] IV) {
  AESEngine aesFastEngine = new AESEngine();
  EthereumIESEngine iesEngine = new EthereumIESEngine(
      new ECDHBasicAgreement(),
      new ConcatKDFBytesGenerator(new SHA256Digest()),
      new HMac(new SHA256Digest()),
      new SHA256Digest(),
      new BufferedBlockCipher(new SICBlockCipher(aesFastEngine)));
  byte[]         d = new byte[] {};
  byte[]         e = new byte[] {};
  IESParameters p = new IESWithCipherParameters(d, e, KEY_SIZE, KEY_SIZE);
  ParametersWithIV parametersWithIV = new ParametersWithIV(p, IV);
  iesEngine.init(isEncrypt, new ECPrivateKeyParameters(prv, curve), new ECPublicKeyParameters(pub, curve), parametersWithIV);
  return iesEngine;
}
origin: ethereum/ethereumj

/**
 * Creates an ECKey that cannot be used for signing, only verifying signatures, from the given encoded point.
 * The compression state of pub will be preserved.
 *
 * @param pub -
 * @return -
 */
public static ECKey fromPublicOnly(byte[] pub) {
  return new ECKey(null, CURVE.getCurve().decodePoint(pub));
}
origin: ethereum/ethereumj

private static ECPoint pub(BigInteger d) {
  return curve.getG().multiply(d);
}
origin: ethereum/ethereumj

/**
 * Decompress a compressed public key (x co-ord and low-bit of y-coord).
 *
 * @param xBN -
 * @param yBit -
 * @return -
 */
private static ECPoint decompressKey(BigInteger xBN, boolean yBit) {
  X9IntegerConverter x9 = new X9IntegerConverter();
  byte[] compEnc = x9.integerToBytes(xBN, 1 + x9.getByteLength(CURVE.getCurve()));
  compEnc[0] = (byte) (yBit ? 0x03 : 0x02);
  return CURVE.getCurve().decodePoint(compEnc);
}
origin: ethereum/ethereumj

/**
 * Utility for compressing an elliptic curve point. Returns the same point if it's already compressed.
 * See the ECKey class docs for a discussion of point compression.
 *
 * @param uncompressed -
 *
 * @return -
 * @deprecated per-point compression property will be removed in Bouncy Castle
 */
public static ECPoint compressPoint(ECPoint uncompressed) {
  return CURVE.getCurve().decodePoint(uncompressed.getEncoded(true));
}
origin: ethereum/ethereumj

private static ECPoint extractPublicKey(final ECPublicKey ecPublicKey) {
 final java.security.spec.ECPoint publicPointW = ecPublicKey.getW();
 final BigInteger xCoord = publicPointW.getAffineX();
 final BigInteger yCoord = publicPointW.getAffineY();
 return CURVE.getCurve().createPoint(xCoord, yCoord);
}
org.spongycastle.crypto.params

Most used classes

  • KeyParameter
  • ParametersWithIV
  • ECDomainParameters
  • ECPrivateKeyParameters
  • ECPublicKeyParameters
  • ParametersWithRandom,
  • RSAPrivateCrtKeyParameters,
  • KDFParameters,
  • RSAKeyParameters,
  • IESWithCipherParameters,
  • MGFParameters,
  • AEADParameters,
  • DHParameters,
  • RSAKeyGenerationParameters,
  • DHKeyGenerationParameters,
  • DHPublicKeyParameters,
  • IESParameters,
  • RC2Parameters,
  • DHPrivateKeyParameters
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now