/** * Add optional text. * * @param text optional agreed text to add to the MAC. * @return the current builder instance. */ public Builder withText(byte[] text) { this.text = DerUtil.toByteArray(new DERTaggedObject(false, 0, DerUtil.getOctetString(text))); return this; }
/** * Create a basic builder with just the compulsory fields. * * @param algorithmID the algorithm associated with this invocation of the KDF. * @param partyUInfo sender party info. * @param partyVInfo receiver party info. */ public Builder(AlgorithmIdentifier algorithmID, byte[] partyUInfo, byte[] partyVInfo) { this.algorithmID = algorithmID; this.partyUVInfo = DerUtil.getOctetString(partyUInfo); this.partyVInfo = DerUtil.getOctetString(partyVInfo); }
public DERMacData build() { switch (type) { case UNILATERALU: case BILATERALU: return new DERMacData(concatenate(type.getHeader(), DerUtil.toByteArray(idU), DerUtil.toByteArray(idV), DerUtil.toByteArray(ephemDataU), DerUtil.toByteArray(ephemDataV), text)); case UNILATERALV: case BILATERALV: return new DERMacData(concatenate(type.getHeader(), DerUtil.toByteArray(idV), DerUtil.toByteArray(idU), DerUtil.toByteArray(ephemDataV), DerUtil.toByteArray(ephemDataU), text)); } throw new IllegalStateException("Unknown type encountered in build"); // should never happen }
/** * Create a basic builder with just the compulsory fields. * * @param type the MAC header * @param idU sender party ID. * @param idV receiver party ID. * @param ephemDataU ephemeral data from sender. * @param ephemDataV ephemeral data from receiver. */ public Builder(Type type, byte[] idU, byte[] idV, byte[] ephemDataU, byte[] ephemDataV) { this.type = type; this.idU = DerUtil.getOctetString(idU); this.idV = DerUtil.getOctetString(idV); this.ephemDataU = DerUtil.getOctetString(ephemDataU); this.ephemDataV = DerUtil.getOctetString(ephemDataV); }
/** * Add optional supplementary public info (DER tagged, implicit, 0). * * @param suppPubInfo supplementary public info. * @return the current builder instance. */ public Builder withSuppPubInfo(byte[] suppPubInfo) { this.suppPubInfo = new DERTaggedObject(false, 0, DerUtil.getOctetString(suppPubInfo)); return this; }
/** * Add optional supplementary private info (DER tagged, implicit, 1). * * @param suppPrivInfo supplementary private info. * @return the current builder instance. */ public Builder withSuppPrivInfo(byte[] suppPrivInfo) { this.suppPrivInfo = new DERTaggedObject(false, 1, DerUtil.getOctetString(suppPrivInfo)); return this; }