private void initParams(Hashtable parameters) { Enumeration keys = parameters.keys(); final Vector pre = new Vector(); final Vector post = new Vector(); while (keys.hasMoreElements()) { Integer type = (Integer)keys.nextElement(); byte[] value = (byte[])parameters.get(type); if (type.intValue() == PARAM_TYPE_KEY) { this.key = value; } else if (type.intValue() < PARAM_TYPE_MESSAGE) { pre.addElement(new Parameter(type.intValue(), value)); } else { post.addElement(new Parameter(type.intValue(), value)); } } preMessageParameters = new Parameter[pre.size()]; pre.copyInto(preMessageParameters); sort(preMessageParameters); postMessageParameters = new Parameter[post.size()]; post.copyInto(postMessageParameters); sort(postMessageParameters); }
private void initParams(Hashtable parameters) { Enumeration keys = parameters.keys(); final Vector pre = new Vector(); final Vector post = new Vector(); while (keys.hasMoreElements()) { Integer type = (Integer)keys.nextElement(); byte[] value = (byte[])parameters.get(type); if (type.intValue() == PARAM_TYPE_KEY) { this.key = value; } else if (type.intValue() < PARAM_TYPE_MESSAGE) { pre.addElement(new Parameter(type.intValue(), value)); } else { post.addElement(new Parameter(type.intValue(), value)); } } preMessageParameters = new Parameter[pre.size()]; pre.copyInto(preMessageParameters); sort(preMessageParameters); postMessageParameters = new Parameter[post.size()]; post.copyInto(postMessageParameters); sort(postMessageParameters); }
public int doFinal(byte[] out, int outOff) { checkInitialised(); if (out.length < (outOff + outputSizeBytes)) { throw new OutputLengthException("Output buffer is too short to hold output"); } // Finalise message block ubiFinal(); // Process additional post-message parameters if (postMessageParameters != null) { for (int i = 0; i < postMessageParameters.length; i++) { Parameter param = postMessageParameters[i]; ubiComplete(param.getType(), param.getValue()); } } // Perform the output transform final int blockSize = getBlockSize(); final int blocksRequired = ((outputSizeBytes + blockSize - 1) / blockSize); for (int i = 0; i < blocksRequired; i++) { final int toWrite = Math.min(blockSize, outputSizeBytes - (i * blockSize)); output(i, out, outOff + (i * blockSize), toWrite); } reset(); return outputSizeBytes; }
public int doFinal(byte[] out, int outOff) { checkInitialised(); if (out.length < (outOff + outputSizeBytes)) { throw new DataLengthException("Output buffer is too short to hold output of " + outputSizeBytes + " bytes"); } // Finalise message block ubiFinal(); // Process additional post-message parameters if (postMessageParameters != null) { for (int i = 0; i < postMessageParameters.length; i++) { Parameter param = postMessageParameters[i]; ubiComplete(param.getType(), param.getValue()); } } // Perform the output transform final int blockSize = getBlockSize(); final int blocksRequired = ((outputSizeBytes + blockSize - 1) / blockSize); for (int i = 0; i < blocksRequired; i++) { final int toWrite = Math.min(blockSize, outputSizeBytes - (i * blockSize)); output(i, out, outOff + (i * blockSize), toWrite); } reset(); return outputSizeBytes; }
private static void sort(Parameter[] params) { if (params == null) { return; } // Insertion sort, for Java 1.1 compatibility for (int i = 1; i < params.length; i++) { Parameter param = params[i]; int hole = i; while (hole > 0 && param.getType() < params[hole - 1].getType()) { params[hole] = params[hole - 1]; hole = hole - 1; } params[hole] = param; } }
private static void sort(Parameter[] params) { if (params == null) { return; } // Insertion sort, for Java 1.1 compatibility for (int i = 1; i < params.length; i++) { Parameter param = params[i]; int hole = i; while (hole > 0 && param.getType() < params[hole - 1].getType()) { params[hole] = params[hole - 1]; hole = hole - 1; } params[hole] = param; } }