678 lines · 20.5 KB · Java
RawDownload
            c = ((b<<30) | (b>>>(32-30)));            b = a;            a = temp;        }         // Round 2        for (int i = 20; i < 40; i++) {            temp = ((a<<5) | (a>>>(32-5))) +                (b ^ c ^ d) + e + W[i] + round2_kt;            e = d;            d = c;            c = ((b<<30) | (b>>>(32-30)));            b = a;            a = temp;        }         // Round 3        for (int i = 40; i < 60; i++) {            temp = ((a<<5) | (a>>>(32-5))) +                ((b&c)|(b&d)|(c&d)) + e + W[i] + round3_kt;            e = d;            d = c;            c = ((b<<30) | (b>>>(32-30)));            b = a;            a = temp;        }         // Round 4        for (int i = 60; i < 80; i++) {            temp = ((a<<5) | (a>>>(32-5))) +                (b ^ c ^ d) + e + W[i] + round4_kt;            e = d;            d = c;            c = ((b<<30) | (b>>>(32-30)));            b = a;            a = temp;        }       int[] md = new int[5];       md[0] = h[0] + a;       md[1] = h[1] + b;       md[2] = h[2] + c;       md[3] = h[3] + d;       md[4] = h[4] + e;       return md;   }      /**     * This implementation recognizes the following parameter:<dl>     *     * <dt><tt>Kseed</tt>     *     * <dd>a byte array.     *     * </dl>     *     * @deprecated     */    @Deprecated    protected void engineSetParameter(String key, Object param) {        if (key.equals("KSEED")) {            if (param instanceof byte[]) {                Kseed = byteArray2IntArray((byte[])param);                KseedAsByteArray = (byte[])param;            } else {                debug("unrecognized param: " + key);                throw new InvalidParameterException("Kseed not a byte array");            }        } else {            throw new InvalidParameterException("invalid parameter");        }    }     /**     * Return the value of the requested parameter. Recognized     * parameters are:     *     * <dl>     *     * <dt><tt>Kseed</tt>     *     * <dd>a byte array.     *     * </dl>     *     * @return the value of the requested parameter.     *     * @see java.security.SignatureEngine     *     * @deprecated     */    @Deprecated    protected Object engineGetParameter(String key) {        if (key.equals("KSEED")) {            return KseedAsByteArray;        } else {            return null;        }    }     /**     * Set the algorithm object.     */    private void setParams(DSAParams params) throws InvalidKeyException {        if (params == null) {            throw new InvalidKeyException("DSA public key lacks parameters");        }        this.params = params;        this.presetP = params.getP();        this.presetQ = params.getQ();        this.presetG = params.getG();    }     /**     * Return a human readable rendition of the engine.     */    public String toString() {        String printable = "DSA Signature";        if (presetP != null && presetQ != null && presetG != null) {            printable += "\n\tp: " + Debug.toHexString(presetP);            printable += "\n\tq: " + Debug.toHexString(presetQ);            printable += "\n\tg: " + Debug.toHexString(presetG);        } else {            printable += "\n\t P, Q or G not initialized.";        }        if (presetY != null) {            printable += "\n\ty: " + Debug.toHexString(presetY);        }        if (presetY == null && presetX == null) {            printable += "\n\tUNINIIALIZED";        }        return printable;    }     /*     * Utility routine for converting a byte array into an int array     */    private int[] byteArray2IntArray(byte[] byteArray) {         int j = 0;        byte[] newBA;        int mod = byteArray.length % 4;         // guarantee that the incoming byteArray is a multiple of 4        // (pad with 0's)        switch (mod) {            case 3:     newBA = new byte[byteArray.length + 1]; break;            case 2:     newBA = new byte[byteArray.length + 2]; break;            case 1:     newBA = new byte[byteArray.length + 3]; break;            default:    newBA = new byte[byteArray.length + 0]; break;        }        System.arraycopy(byteArray, 0, newBA, 0, byteArray.length);         // copy each set of 4 bytes in the byte array into an integer        int[] newSeed = new int[newBA.length / 4];        for (int i = 0; i < newBA.length; i += 4) {            newSeed[j] = newBA[i + 3] & 0xFF;            newSeed[j] |= (newBA[i + 2] << 8) & 0xFF00;            newSeed[j] |= (newBA[i + 1] << 16) & 0xFF0000;            newSeed[j] |= (newBA[i + 0] << 24) & 0xFF000000;            j++;        }         return newSeed;    }     private static void debug(Exception e) {        if (debug) {            e.printStackTrace();        }    }     private static void debug(String s) {        if (debug) {            System.err.println(s);        }    }}

Lines 501–678 of 678. Previous lines

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t