Example usage for org.bouncycastle.util Memoable copy

List of usage examples for org.bouncycastle.util Memoable copy

Introduction

In this page you can find the example usage for org.bouncycastle.util Memoable copy.

Prototype

Memoable copy();

Source Link

Document

Produce a copy of this object with its configuration and in its current state.

Usage

From source file:com.joyent.manta.util.HmacCloner.java

License:Open Source License

@Override
public HMac createClone(final HMac source) {
    final Digest originalDigest = source.getUnderlyingDigest();
    final Digest clonedDigest = new DigestCloner().createClone(originalDigest);
    final HMac cloned = new HMac(clonedDigest);

    try {// w  ww  .  jav  a2  s  .  c  om
        final Memoable ipadState = (Memoable) readField(FIELD_IPAD_STATE, source, true);
        final Memoable opadState = (Memoable) readField(FIELD_OPAD_STATE, source, true);

        writeField(FIELD_IPAD_STATE, cloned, ipadState.copy());
        writeField(FIELD_OPAD_STATE, cloned, opadState.copy());
    } catch (IllegalAccessException e) {
        throw new MantaReflectionException(e);
    }

    return cloned;
}