// 
// Decompiled by Procyon v0.6.0
// 

package org.bouncycastle.pqc.crypto.lms;

import java.io.IOException;
import org.bouncycastle.crypto.CipherParameters;
import org.bouncycastle.pqc.crypto.MessageSigner;

public class HSSSigner implements MessageSigner
{
    private HSSPrivateKeyParameters privKey;
    private HSSPublicKeyParameters pubKey;
    
    @Override
    public void init(final boolean b, final CipherParameters cipherParameters) {
        if (b) {
            this.privKey = (HSSPrivateKeyParameters)cipherParameters;
        }
        else {
            this.pubKey = (HSSPublicKeyParameters)cipherParameters;
        }
    }
    
    @Override
    public byte[] generateSignature(final byte[] array) {
        try {
            return HSS.generateSignature(this.privKey, array).getEncoded();
        }
        catch (final IOException ex) {
            throw new IllegalStateException("unable to encode signature: " + ex.getMessage());
        }
    }
    
    @Override
    public boolean verifySignature(final byte[] array, final byte[] array2) {
        try {
            return HSS.verifySignature(this.pubKey, HSSSignature.getInstance(array2, this.pubKey.getL()), array);
        }
        catch (final IOException ex) {
            throw new IllegalStateException("unable to decode signature: " + ex.getMessage());
        }
    }
}
