Example usage for org.bouncycastle.crypto.params IESParameters getDerivationV

List of usage examples for org.bouncycastle.crypto.params IESParameters getDerivationV

Introduction

In this page you can find the example usage for org.bouncycastle.crypto.params IESParameters getDerivationV.

Prototype

public byte[] getDerivationV() 

Source Link

Usage

From source file:dorkbox.util.crypto.CryptoECC.java

License:Apache License

@SuppressWarnings("RedundantIfStatement")
public static boolean compare(IESParameters cipherAParams, IESParameters cipherBParams) {
    if (!Arrays.equals(cipherAParams.getDerivationV(), cipherBParams.getDerivationV())) {
        return false;
    }//from ww w . j a va  2 s . com
    if (!Arrays.equals(cipherAParams.getEncodingV(), cipherBParams.getEncodingV())) {
        return false;
    }

    if (cipherAParams.getMacKeySize() != cipherBParams.getMacKeySize()) {
        return false;
    }
    return true;
}

From source file:dorkbox.util.serialization.IesParametersSerializer.java

License:Apache License

@Override
public void write(Kryo kryo, Output output, IESParameters key) {
    byte[] bytes;
    int length;/*from   w  ww .ja  v a 2  s  . co  m*/

    ///////////
    bytes = key.getDerivationV();
    length = bytes.length;

    output.writeInt(length, true);
    output.writeBytes(bytes, 0, length);

    ///////////
    bytes = key.getEncodingV();
    length = bytes.length;

    output.writeInt(length, true);
    output.writeBytes(bytes, 0, length);

    ///////////
    output.writeInt(key.getMacKeySize(), true);
}

From source file:org.forgerock.openicf.framework.remote.security.ECIESEncryptor.java

License:Open Source License

protected byte[] doFinal(byte[] bytes, IESParameters params, boolean encrypt) {
    try {//from   w  w w.j a va 2  s  .  c  om
        final IESEngine engine = initialiseEngine(encrypt, privateKeyParameter, publicKeyParameter,
                new IESParameters(params.getDerivationV(), params.getEncodingV(), params.getMacKeySize()));
        return engine.processBlock(bytes, 0, bytes.length);
    } catch (InvalidCipherTextException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}

From source file:org.forgerock.openicf.framework.remote.security.ECIESEncryptor.java

License:Open Source License

@Override
public byte[] encrypt(byte[] bytes) {
    IESParameters parameters = generateIESParameterSpec();
    byte[] encrypted = doFinal(bytes, parameters, true);
    byte[] result = new byte[32 + encrypted.length];

    System.arraycopy(parameters.getDerivationV(), 0, result, 0, 16);
    System.arraycopy(parameters.getEncodingV(), 0, result, 16, 16);
    System.arraycopy(encrypted, 0, result, 32, encrypted.length);

    return result;
}