@Test public void testnonceGenerationCommonIVNull() throws OSException { exception.expect(NullPointerException.class); OSSerializer.nonceGeneration(partialIV, sid, null, ctx.getIVLength()); }
public static byte[] nonceGeneration(byte[] partialIV, byte[] senderID, byte[] commonIV, int nonceLength) throws OSException { if (partialIV != null) { if (senderID != null) { if (commonIV != null) { if (nonceLength > 0) { int s = senderID.length; int zeroes = 5 - partialIV.length; if (zeroes > 0) { partialIV = leftPaddingZeroes(partialIV, zeroes); } zeroes = (nonceLength - 6) - senderID.length; if (zeroes > 0) { senderID = leftPaddingZeroes(senderID, zeroes); } zeroes = nonceLength - commonIV.length; if (zeroes > 0) { commonIV = leftPaddingZeroes(commonIV, zeroes); } byte[] tmp = new byte[1 + senderID.length + partialIV.length]; tmp[0] = (byte) s; System.arraycopy(senderID, 0, tmp, 1, senderID.length); System.arraycopy(partialIV, 0, tmp, senderID.length + 1, partialIV.length); byte[] result = new byte[commonIV.length]; int i = 0; for (byte b : tmp) { result[i] = (byte) (b ^ commonIV[i++]); } return result; } else { LOGGER.error(ErrorDescriptions.NONCE_LENGTH_INVALID); throw new IllegalArgumentException(ErrorDescriptions.NONCE_LENGTH_INVALID); } } else { LOGGER.error(ErrorDescriptions.COMMON_IV_NULL); throw new NullPointerException(ErrorDescriptions.COMMON_IV_NULL); } } else { LOGGER.error(ErrorDescriptions.SENDER_ID_NULL); throw new NullPointerException(ErrorDescriptions.SENDER_ID_NULL); } } else { LOGGER.error(ErrorDescriptions.PARTIAL_IV_NULL); throw new NullPointerException(ErrorDescriptions.PARTIAL_IV_NULL); } }
OSSerializer { public static byte[] nonceGeneration(byte[] partialIV, byte[] senderID, byte[] commonIV, int nonceLength) throws OSException { if (partialIV != null) { if (senderID != null) { if (commonIV != null) { if (nonceLength > 0) { int s = senderID.length; int zeroes = 5 - partialIV.length; if (zeroes > 0) { partialIV = leftPaddingZeroes(partialIV, zeroes); } zeroes = (nonceLength - 6) - senderID.length; if (zeroes > 0) { senderID = leftPaddingZeroes(senderID, zeroes); } zeroes = nonceLength - commonIV.length; if (zeroes > 0) { commonIV = leftPaddingZeroes(commonIV, zeroes); } byte[] tmp = new byte[1 + senderID.length + partialIV.length]; tmp[0] = (byte) s; System.arraycopy(senderID, 0, tmp, 1, senderID.length); System.arraycopy(partialIV, 0, tmp, senderID.length + 1, partialIV.length); byte[] result = new byte[commonIV.length]; int i = 0; for (byte b : tmp) { result[i] = (byte) (b ^ commonIV[i++]); } return result; } else { LOGGER.error(ErrorDescriptions.NONCE_LENGTH_INVALID); throw new IllegalArgumentException(ErrorDescriptions.NONCE_LENGTH_INVALID); } } else { LOGGER.error(ErrorDescriptions.COMMON_IV_NULL); throw new NullPointerException(ErrorDescriptions.COMMON_IV_NULL); } } else { LOGGER.error(ErrorDescriptions.SENDER_ID_NULL); throw new NullPointerException(ErrorDescriptions.SENDER_ID_NULL); } } else { LOGGER.error(ErrorDescriptions.PARTIAL_IV_NULL); throw new NullPointerException(ErrorDescriptions.PARTIAL_IV_NULL); } } }
OSSerializer { public static byte[] nonceGeneration(byte[] partialIV, byte[] senderID, byte[] commonIV, int nonceLength) throws OSException { if (partialIV != null) { if (senderID != null) { if (commonIV != null) { if (nonceLength > 0) { int s = senderID.length; int zeroes = 5 - partialIV.length; if (zeroes > 0) { partialIV = leftPaddingZeroes(partialIV, zeroes); } zeroes = (nonceLength - 6) - senderID.length; if (zeroes > 0) { senderID = leftPaddingZeroes(senderID, zeroes); } zeroes = nonceLength - commonIV.length; if (zeroes > 0) { commonIV = leftPaddingZeroes(commonIV, zeroes); } byte[] tmp = new byte[1 + senderID.length + partialIV.length]; tmp[0] = (byte) s; System.arraycopy(senderID, 0, tmp, 1, senderID.length); System.arraycopy(partialIV, 0, tmp, senderID.length + 1, partialIV.length); byte[] result = new byte[commonIV.length]; int i = 0; for (byte b : tmp) { result[i] = (byte) (b ^ commonIV[i++]); } return result; } else { LOGGER.error(ErrorDescriptions.NONCE_LENGTH_INVALID); throw new IllegalArgumentException(ErrorDescriptions.NONCE_LENGTH_INVALID); } } else { LOGGER.error(ErrorDescriptions.COMMON_IV_NULL); throw new NullPointerException(ErrorDescriptions.COMMON_IV_NULL); } } else { LOGGER.error(ErrorDescriptions.SENDER_ID_NULL); throw new NullPointerException(ErrorDescriptions.SENDER_ID_NULL); } } else { LOGGER.error(ErrorDescriptions.PARTIAL_IV_NULL); throw new NullPointerException(ErrorDescriptions.PARTIAL_IV_NULL); } }  }
OSSerializer { public static byte[] nonceGeneration(byte[] partialIV, byte[] senderID, byte[] commonIV, int nonceLength) throws OSException { if (partialIV != null) { if (senderID != null) { if (commonIV != null) { if (nonceLength > 0) { int s = senderID.length; int zeroes = 5 - partialIV.length; if (zeroes > 0) { partialIV = leftPaddingZeroes(partialIV, zeroes); } zeroes = (nonceLength - 6) - senderID.length; if (zeroes > 0) { senderID = leftPaddingZeroes(senderID, zeroes); } zeroes = nonceLength - commonIV.length; if (zeroes > 0) { commonIV = leftPaddingZeroes(commonIV, zeroes); } byte[] tmp = new byte[1 + senderID.length + partialIV.length]; tmp[0] = (byte) s; System.arraycopy(senderID, 0, tmp, 1, senderID.length); System.arraycopy(partialIV, 0, tmp, senderID.length + 1, partialIV.length); byte[] result = new byte[commonIV.length]; int i = 0; for (byte b : tmp) { result[i] = (byte) (b ^ commonIV[i++]); } return result; } else { LOGGER.error(ErrorDescriptions.NONCE_LENGTH_INVALID); throw new IllegalArgumentException(ErrorDescriptions.NONCE_LENGTH_INVALID); } } else { LOGGER.error(ErrorDescriptions.COMMON_IV_NULL); throw new NullPointerException(ErrorDescriptions.COMMON_IV_NULL); } } else { LOGGER.error(ErrorDescriptions.SENDER_ID_NULL); throw new NullPointerException(ErrorDescriptions.SENDER_ID_NULL); } } else { LOGGER.error(ErrorDescriptions.PARTIAL_IV_NULL); throw new NullPointerException(ErrorDescriptions.PARTIAL_IV_NULL); } }  static byte[] serializeConfidentialData(OptionSet options, byte[] payload, int realCode); static byte[] serializeAAD(int version, AlgorithmID algorithm, int requestSeq, byte[] requestSenderId, OptionSet options); static byte[] nonceGeneration(byte[] partialIV, byte[] senderID, byte[] commonIV, int nonceLength); static byte[] leftPaddingZeroes(byte[] paddMe, int zeros); static byte[] processPartialIV(int value); static byte[] stripZeroes(byte[] in); }
OSSerializer { public static byte[] nonceGeneration(byte[] partialIV, byte[] senderID, byte[] commonIV, int nonceLength) throws OSException { if (partialIV != null) { if (senderID != null) { if (commonIV != null) { if (nonceLength > 0) { int s = senderID.length; int zeroes = 5 - partialIV.length; if (zeroes > 0) { partialIV = leftPaddingZeroes(partialIV, zeroes); } zeroes = (nonceLength - 6) - senderID.length; if (zeroes > 0) { senderID = leftPaddingZeroes(senderID, zeroes); } zeroes = nonceLength - commonIV.length; if (zeroes > 0) { commonIV = leftPaddingZeroes(commonIV, zeroes); } byte[] tmp = new byte[1 + senderID.length + partialIV.length]; tmp[0] = (byte) s; System.arraycopy(senderID, 0, tmp, 1, senderID.length); System.arraycopy(partialIV, 0, tmp, senderID.length + 1, partialIV.length); byte[] result = new byte[commonIV.length]; int i = 0; for (byte b : tmp) { result[i] = (byte) (b ^ commonIV[i++]); } return result; } else { LOGGER.error(ErrorDescriptions.NONCE_LENGTH_INVALID); throw new IllegalArgumentException(ErrorDescriptions.NONCE_LENGTH_INVALID); } } else { LOGGER.error(ErrorDescriptions.COMMON_IV_NULL); throw new NullPointerException(ErrorDescriptions.COMMON_IV_NULL); } } else { LOGGER.error(ErrorDescriptions.SENDER_ID_NULL); throw new NullPointerException(ErrorDescriptions.SENDER_ID_NULL); } } else { LOGGER.error(ErrorDescriptions.PARTIAL_IV_NULL); throw new NullPointerException(ErrorDescriptions.PARTIAL_IV_NULL); } }  static byte[] serializeConfidentialData(OptionSet options, byte[] payload, int realCode); static byte[] serializeAAD(int version, AlgorithmID algorithm, int requestSeq, byte[] requestSenderId, OptionSet options); static byte[] nonceGeneration(byte[] partialIV, byte[] senderID, byte[] commonIV, int nonceLength); static byte[] leftPaddingZeroes(byte[] paddMe, int zeros); static byte[] processPartialIV(int value); static byte[] stripZeroes(byte[] in);  }