Example usage for org.bouncycastle.asn1 ASN1Integer getInstance

List of usage examples for org.bouncycastle.asn1 ASN1Integer getInstance

Introduction

In this page you can find the example usage for org.bouncycastle.asn1 ASN1Integer getInstance.

Prototype

public static ASN1Integer getInstance(Object obj) 

Source Link

Document

Return an integer from the passed in object.

Usage

From source file:org.cryptoworkshop.ximix.common.asn1.message.BigIntegerMessage.java

License:Apache License

public static final BigIntegerMessage getInstance(Object o) {
    if (o instanceof BigIntegerMessage) {
        return (BigIntegerMessage) o;
    } else if (o != null) {
        return new BigIntegerMessage(ASN1Integer.getInstance(o));
    }/*from   ww  w  . ja v a  2s.c  o m*/

    return null;
}

From source file:org.cryptoworkshop.ximix.common.asn1.message.BoardDetailMessage.java

License:Apache License

private BoardDetailMessage(ASN1Sequence seq) {
    this.boardName = DERUTF8String.getInstance(seq.getObjectAt(0)).getString();
    this.host = DERUTF8String.getInstance(seq.getObjectAt(1)).getString();
    messageCount = ASN1Integer.getInstance(seq.getObjectAt(2)).getValue().intValue();

    if (seq.size() > 3) {
        this.backupHost = DERUTF8String.getInstance(seq.getObjectAt(3)).getString();
    } else {/*from ww w .  j  ava2  s  .  com*/
        this.backupHost = null;
    }
}

From source file:org.cryptoworkshop.ximix.common.asn1.message.BoardDownloadMessage.java

License:Apache License

private BoardDownloadMessage(ASN1Sequence seq) {
    this.boardName = DERUTF8String.getInstance(seq.getObjectAt(0)).getString();
    this.maxNumberOfMessages = ASN1Integer.getInstance(seq.getObjectAt(1)).getValue().intValue();
}

From source file:org.cryptoworkshop.ximix.common.asn1.message.BoardUploadBlockMessage.java

License:Apache License

private BoardUploadBlockMessage(ASN1Sequence seq) {
    this.operationNumber = ASN1Integer.getInstance(seq.getObjectAt(0)).getValue().longValue();
    this.boardName = DERUTF8String.getInstance(seq.getObjectAt(1)).getString();
    this.stepNumber = ASN1Integer.getInstance(seq.getObjectAt(2)).getValue().intValue();
    this.messageBlock = PostedMessageBlock.getInstance(seq.getObjectAt(3));
}

From source file:org.cryptoworkshop.ximix.common.asn1.message.BoardUploadIndexedMessage.java

License:Apache License

private BoardUploadIndexedMessage(ASN1Sequence seq) {
    this.boardName = DERUTF8String.getInstance(seq.getObjectAt(0)).getString();
    this.index = ASN1Integer.getInstance(seq.getObjectAt(1)).getValue().intValue();

    ASN1Sequence dataBlock = ASN1Sequence.getInstance(seq.getObjectAt(2));

    this.data = new byte[dataBlock.size()][];

    for (int i = 0; i != dataBlock.size(); i++) {
        data[i] = ASN1OctetString.getInstance(dataBlock.getObjectAt(i)).getOctets();
    }//from  www  . j  av a  2 s . c  o m
}

From source file:org.cryptoworkshop.ximix.common.asn1.message.ChallengeLogMessage.java

License:Apache License

private ChallengeLogMessage(ASN1Sequence seq) {
    this.index = ASN1Integer.getInstance(seq.getObjectAt(0)).getValue().intValue();
    this.sequenceNo = ASN1Integer.getInstance(seq.getObjectAt(1)).getValue().intValue();
    this.hasPassed = ASN1Boolean.getInstance(seq.getObjectAt(2)).isTrue();
    this.keyInfo = SubjectPublicKeyInfo.getInstance(seq.getObjectAt(3));

    ECPublicKeyParameters ecKey;/*from   ww w . jav  a2  s  . co m*/
    try {
        ecKey = (ECPublicKeyParameters) PublicKeyFactory.createKey(keyInfo);
    } catch (IOException e) {
        throw new IllegalArgumentException("Unable to create EC key from keyInfo in sequence.");
    }

    ECCurve curve = ecKey.getParameters().getCurve();

    this.sourceMessage = PointSequence.getInstance(curve, ASN1Sequence.getInstance(seq.getObjectAt(4)))
            .getECPoints();

    ASN1Sequence proofS = ASN1Sequence.getInstance(seq.getObjectAt(5));
    decryptionProofs = new ECDecryptionProof[proofS.size()];

    for (int i = 0; i != decryptionProofs.length; i++) {
        ASN1Sequence proof = ASN1Sequence.getInstance(proofS.getObjectAt(i));
        decryptionProofs[i] = new ECDecryptionProof(
                curve.decodePoint(ASN1OctetString.getInstance(proof.getObjectAt(0)).getOctets()),
                curve.decodePoint(ASN1OctetString.getInstance(proof.getObjectAt(1)).getOctets()),
                ASN1Integer.getInstance(proof.getObjectAt(2)).getValue());
    }
}

From source file:org.cryptoworkshop.ximix.common.asn1.message.CopyAndMoveMessage.java

License:Apache License

private CopyAndMoveMessage(ASN1Sequence seq) {
    this.operationNumber = ASN1Integer.getInstance(seq.getObjectAt(0)).getValue().longValue();
    this.boardName = DERUTF8String.getInstance(seq.getObjectAt(1)).getString();
    this.stepNumber = ASN1Integer.getInstance(seq.getObjectAt(2)).getValue().intValue();
    this.nodeName = DERUTF8String.getInstance(seq.getObjectAt(3)).getString();
}

From source file:org.cryptoworkshop.ximix.common.asn1.message.DownloadShuffledBoardMessage.java

License:Apache License

private DownloadShuffledBoardMessage(ASN1Sequence seq) {
    this.keyID = DERUTF8String.getInstance(seq.getObjectAt(0)).getString();
    this.boardName = DERUTF8String.getInstance(seq.getObjectAt(1)).getString();
    this.blockSize = ASN1Integer.getInstance(seq.getObjectAt(2)).getValue().intValue();
}

From source file:org.cryptoworkshop.ximix.common.asn1.message.KeyGenerationMessage.java

License:Apache License

private KeyGenerationMessage(ASN1Sequence seq) {
    this.algorithm = Algorithm.values()[ASN1Enumerated.getInstance(seq.getObjectAt(0)).getValue().intValue()];
    this.keyID = DERUTF8String.getInstance(seq.getObjectAt(1)).getString();
    this.keyGenParameters = KeyGenParams.getInstance(seq.getObjectAt(2));
    this.threshold = ASN1Integer.getInstance(seq.getObjectAt(3)).getValue().intValue();
    this.nodesToUse = toList(ASN1Sequence.getInstance(seq.getObjectAt(4)));
}

From source file:org.cryptoworkshop.ximix.common.asn1.message.KeyGenerationParameters.java

License:Apache License

public static final KeyGenerationParameters getInstance(Object o) {
    if (o instanceof KeyGenerationParameters) {
        return (KeyGenerationParameters) o;
    } else if (o != null) {
        ASN1Sequence seq = ASN1Sequence.getInstance(o);

        if (ASN1Integer.getInstance(seq.getObjectAt(0)).getValue().intValue() == NAMED_PARAMETER_SET) {
            return new NamedKeyGenParams(seq);
        }//w  w  w . j av a2s .  c  om
    }

    return null;
}