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

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

Introduction

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

Prototype

public byte[] getEncodingV() 

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 w w  w . j av  a2  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;/*w ww. j  ava  2  s  . com*/

    ///////////
    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 ww w.java  2  s  . co m
        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;
}