亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? rawelgamalcipher.java

?? jpeg2000編解碼
?? JAVA
字號:
// $Id: RawElGamalCipher.java,v 1.1.1.1 2002/08/27 12:32:10 grosbois Exp $//// $Log: RawElGamalCipher.java,v $// Revision 1.1.1.1  2002/08/27 12:32:10  grosbois// Add cryptix 3.2//// Revision 1.3  2000/08/17 11:40:54  edwin// java.* -> xjava.*//// Revision 1.2  1997/12/07 06:37:26  hopwood// + Major overhaul of ElGamal to match RSA.//// Revision 1.1.1.1  1997/11/03 22:36:56  hopwood// + Imported to CVS (tagged as 'start').//// $Endlog$/* * Copyright (c) 1997 Systemics Ltd * on behalf of the Cryptix Development Team.  All rights reserved. */package cryptix.provider.elgamal;import cryptix.CryptixException;import cryptix.util.core.ArrayUtil;import java.math.BigInteger;import java.util.Random;import java.security.SecureRandom;import xjava.security.Cipher;import xjava.security.AsymmetricCipher;import java.security.Key;import java.security.KeyException;import java.security.InvalidKeyException;import java.security.InvalidParameterException;import xjava.security.IllegalBlockSizeException;import xjava.security.interfaces.ElGamalPublicKey;import xjava.security.interfaces.ElGamalPrivateKey;// needed only for test codeimport java.io.PrintWriter;import java.security.KeyPair;import java.security.KeyPairGenerator;/** * The raw ElGamal encryption algorithm. * <p> * <b>References:</b> * <ol> *   <li> Bruce Schneier, *        "Section 19.6 ElGamal," *        <cite>Applied Cryptography, 2nd edition</cite>, *        John Wiley &amp; Sons, 1996. * </ol> * <p> * <b>Copyright</b> &copy; 1997 * <a href="http://www.systemics.com/">Systemics Ltd</a> on behalf of the * <a href="http://www.systemics.com/docs/cryptix/">Cryptix Development Team</a>. * <br>All rights reserved. * <p> * <b>$Revision: 1.1.1.1 $</b> * @author  David Hopwood * @since   Cryptix 2.2.2 */public class RawElGamalCipherextends Cipherimplements AsymmetricCipher, Cloneable {    private static final int POSITIVE = 1;    private static final BigInteger ONE = BigInteger.valueOf(1);    private BigInteger p;    private BigInteger p_minus_1;    private BigInteger g;    private BigInteger x; // null if the state is ENCRYPT    private BigInteger y;    private int primeLen;    private Random rng;    /**     * Constructor for a RawElGamalCipher.     */    public RawElGamalCipher() {        super(false, true, "Cryptix");    }    /**     * <b>SPI</b>: Initializes the cipher for encryption, using the     * given public key. The key object must implement     * java.security.interfaces.ElGamalPublicKey.     *     * @param key   the public key     * @exception InvalidKeyException if !(key instanceof     *          java.security.interfaces.ElGamalPublicKey), or the     *          key is otherwise invalid     */    protected void engineInitEncrypt(Key key) throws KeyException {        if (!(key instanceof ElGamalPublicKey))            throw new InvalidKeyException("ElGamal: encryption key does not " +                "implement java.security.interfaces.ElGamalPublicKey");        ElGamalPublicKey elgamalKey = (ElGamalPublicKey) key;        initInternal(elgamalKey.getP(), elgamalKey.getG(),                     null, elgamalKey.getY());        if (rng == null)            rng = new SecureRandom();    }    /**     * <b>SPI</b>: Initializes the cipher for decryption, using the     * given private key. The key object must implement     * java.security.interfaces.ElGamalPrivateKey.     *     * @param key   the private key     * @exception InvalidKeyException if !(key instanceof     *          java.security.interfaces.ElGamalPrivateKey), or the     *          key is otherwise invalid     */    protected void engineInitDecrypt(Key key) throws KeyException {        if (!(key instanceof ElGamalPrivateKey))            throw new InvalidKeyException("ElGamal: decryption key does not " +                "implement java.security.interfaces.ElGamalPrivateKey");        ElGamalPrivateKey elgamalKey = (ElGamalPrivateKey) key;        BigInteger newX = elgamalKey.getX();        if (newX == null) throw new InvalidKeyException("ElGamal: getX() == null");        initInternal(elgamalKey.getP(), elgamalKey.getG(),                     newX, elgamalKey.getY());    }    private void initInternal(BigInteger newP, BigInteger newG,                              BigInteger newX, BigInteger newY)            throws InvalidKeyException {        if (newP == null) throw new InvalidKeyException("ElGamal: getP() == null");        if (newG == null) throw new InvalidKeyException("ElGamal: getG() == null");        if (newY == null) throw new InvalidKeyException("ElGamal: getY() == null");        p = newP;        g = newG;        x = newX;        y = newY;        primeLen = (p.bitLength() - 1) / 8;    }    /**     * <b>SPI</b>: Return the plaintext block size, in bytes. For ElGamal this     * is the number of bytes needed for a bit string one bit shorter than the     * prime, <i>p</i>.     * <p>     * If the key has not been set, this method throws CryptixException (a subclass     * of <a href=java.security.ProviderException.html>ProviderException</a>).     *     * @return the plaintext block size     */    protected int enginePlaintextBlockSize() {        if (primeLen == 0) throw new CryptixException(            "ElGamal: plaintext block size is not valid until key is set");        return primeLen;    }    /**     * <b>SPI</b>: Return the ciphertext block size, in bytes. For ElGamal this     * is <strong>double</strong> the number of bytes needed to represent <i>p-1</i>.     * <p>     * If the key has not been set, this method throws CryptixException (a subclass     * of <a href=java.security.ProviderException.html>ProviderException</a>).     *     * @return the ciphertext block size     */    protected int engineCiphertextBlockSize() {        if (primeLen == 0) throw new CryptixException(            "ElGamal: ciphertext block size is not valid until key is set");        return primeLen*2;    }    /**     * <b>SPI</b>: Set an algorithm-specific parameter.     * <p>     * ElGamal has one algorithm-specific parameter called "random", of type     * java.util.Random, which specifies the source of random bits used to     * generate the <i>k</i> values needed for encryption. If this parameter     * is not set when <code>initKey</code> is called, the result of     * <code>new SecureRandom()</code> will be used.     * <p>     * You can set the "random" parameter using the following code:     * <pre>     *   try {     *       elgamal.setParameter("random", existingSecureRandom);     *   } catch (InvalidParameterException e) { /* ignore &#42;/ }     *   elgamal.initEncrypt(publicKey);     * </pre>     * <p>     * This is not useful if the cipher will only be used for decryption.     *     * @param param the string identifier of the parameter.     * @param value the parameter value.     * @exception InvalidParameterException if (!(param.equals("random") &&     *          value instanceof java.util.Random))     */    protected void engineSetParameter(String param, Object value) {        if (param.equals("random")) {            if (!(value instanceof Random)) throw new InvalidParameterException(                "value must be an instance of java.util.Random");            rng = (Random)value;            return;        }        throw new InvalidParameterException(param);    }    /** <b>SPI</b>: Return an algorithm-specific parameter.     * <p>     * ElGamal has one algorithm-specific parameter called "random", as described     * <a href="#engineSetParameter">above</a>. It is guaranteed to be a subclass     * of java.util.Random. Calling this method with a <i>param</i> string     * other than "random" will return null.     *     * @param param the string name of the parameter.     * @return the object that represents the parameter value, or null if there     *          is none.     */    protected Object engineGetParameter(String param) {        if (param.equals("random")) return rng;        return null;    }    /**     * <b>SPI</b>: DOCUMENT ME     */    protected int engineUpdate(byte[] in, int inOffset, int inLen,                               byte[] out, int outOffset) {        if (inLen <= 0) return 0;        if (getState() == ENCRYPT) {            if (inLen != primeLen) throw new IllegalBlockSizeException(                "inLen = " + inLen + ", plaintext block size = " + primeLen);            byte[] plaintext = new byte[primeLen];            System.arraycopy(in, inOffset, plaintext, 0, primeLen);            BigInteger[] ab = new BigInteger[2];            BigInteger M = new BigInteger(POSITIVE, plaintext);            ElGamalAlgorithm.encrypt(M, ab, p, g, y, rng);            byte[] aBytes = ab[0].toByteArray();            byte[] bBytes = ab[1].toByteArray();            ArrayUtil.clear(out, outOffset, primeLen*2);            System.arraycopy(aBytes, 0, out, outOffset + primeLen - aBytes.length,                aBytes.length);            System.arraycopy(bBytes, 0, out, outOffset + primeLen*2 - bBytes.length,                bBytes.length);            // don't leave plaintext hanging about indefinitely.            ArrayUtil.clear(plaintext);            return primeLen*2;        } else {            // getState() == DECRYPT            if (inLen != primeLen*2) throw new IllegalBlockSizeException(                "inLen = " + inLen + ", ciphertext block size = " + primeLen*2);            byte[] ciphertext = new byte[primeLen];            System.arraycopy(in, inOffset, ciphertext, 0, primeLen);            BigInteger a = new BigInteger(POSITIVE, ciphertext);            System.arraycopy(in, inOffset + primeLen, ciphertext, 0, primeLen);            BigInteger b = new BigInteger(POSITIVE, ciphertext);            BigInteger M = ElGamalAlgorithm.decrypt(a, b, p, g, x);            byte[] plaintext = M.toByteArray();            ArrayUtil.clear(out, outOffset, primeLen - plaintext.length);            System.arraycopy(plaintext, 0, out, outOffset + primeLen - plaintext.length,                plaintext.length);            return primeLen;        }    }// Test methods//...........................................................................//// Don't expand this code please without thinking about it,// much better to write a separate program.//    /**     * Entry point for very basic <code>self_test</code>.     */    public static final void main(String[] args) {        try { self_test(new PrintWriter(System.out, true)); }        catch (Exception e) { e.printStackTrace(); }    }    public static void self_test(PrintWriter out)    throws KeyException {        KeyPairGenerator keygen = new BaseElGamalKeyPairGenerator();        SecureRandom random = new SecureRandom();        long start = System.currentTimeMillis();        keygen.initialize(385, random);        KeyPair keypair = keygen.generateKeyPair();        long duration = System.currentTimeMillis() - start;        out.println("Keygen: " + (float)duration/1000 + " seconds");        RawElGamalCipher raw = new RawElGamalCipher();        raw.test(out, keypair, random);    }    private void test(PrintWriter out, KeyPair keypair, SecureRandom random)    throws KeyException {        ElGamalPrivateKey privateKey = (ElGamalPrivateKey) (keypair.getPrivate());        ElGamalPublicKey publicKey = (ElGamalPublicKey) (keypair.getPublic());        BigInteger M = new BigInteger(privateKey.getP().bitLength() - 1, random);        rng = random;        long start = System.currentTimeMillis();        initEncrypt(publicKey);        BigInteger[] ab = new BigInteger[2];        ElGamalAlgorithm.encrypt(M, ab, p, g, y, rng);        long midpoint = System.currentTimeMillis();        initDecrypt(privateKey);        BigInteger Mdash = ElGamalAlgorithm.decrypt(ab[0], ab[1], p, g, x);        long end = System.currentTimeMillis();        out.println("p = " + p);        out.println("g = " + g);        out.println("x = " + x);        out.println("y = " + y);        out.println("M = " + M);        out.println("a = " + ab[0]);        out.println("b = " + ab[1]);        if (!(M.equals(Mdash))) {            out.println("DECRYPTION FAILED!");            out.println("M' = " + Mdash);        }        out.println("Encrypt: " + ((float) (midpoint - start) / 1000) + " seconds");        out.println("Decrypt: " + ((float) (end - midpoint) / 1000) + " seconds");    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一级午夜免费电影| 日韩 欧美一区二区三区| 国内精品视频666| 这里是久久伊人| 亚洲一级在线观看| 日本高清成人免费播放| 国产亚洲成av人在线观看导航| 九九久久精品视频| 欧美精品一区二区三区蜜桃| 狠狠色综合日日| 久久毛片高清国产| 国产精品一区二区久久不卡| 2024国产精品| 国产麻豆一精品一av一免费| 欧美精品一区二区三区蜜桃| 国产自产v一区二区三区c| 欧美欧美欧美欧美首页| 日韩高清不卡一区二区| 日韩午夜在线影院| 看国产成人h片视频| 精品福利一二区| 国产成人夜色高潮福利影视| 日韩精品中文字幕在线不卡尤物| 欧美a一区二区| 久久免费电影网| 成人a级免费电影| 一区二区三区免费在线观看| 91麻豆精品在线观看| 一区二区三区产品免费精品久久75| 色婷婷精品大在线视频| 久久99国产精品久久| 亚洲精品高清在线观看| 日韩欧美亚洲国产另类| 色呦呦网站一区| 精品一区二区在线看| 国产精品国产三级国产普通话99 | 国产一区二区三区日韩| 1区2区3区欧美| 欧美哺乳videos| 91黄视频在线观看| 国产精品亚洲午夜一区二区三区| 亚洲gay无套男同| 亚洲欧洲av另类| 欧美精品一区二区三区高清aⅴ | 国产一区 二区| 亚洲制服欧美中文字幕中文字幕| 久久嫩草精品久久久久| 欧美日韩三级在线| 播五月开心婷婷综合| 久久电影网电视剧免费观看| 亚洲综合另类小说| 亚洲欧美一区二区不卡| 国产色产综合色产在线视频| 欧美电影精品一区二区| 制服丝袜在线91| 欧美日韩精品一二三区| 色综合天天性综合| 成人免费av在线| 国产盗摄女厕一区二区三区| 久久精品国内一区二区三区| 亚洲成人精品一区| 亚洲在线中文字幕| 一区二区三区四区蜜桃| 中文字幕一区二区日韩精品绯色 | 国产欧美日产一区| 久久免费电影网| 精品欧美一区二区三区精品久久| 欧美日韩免费一区二区三区| 欧美日韩视频在线一区二区| 欧美性大战久久久久久久 | 波多野结衣中文字幕一区二区三区| 美腿丝袜在线亚洲一区| 欧美bbbbb| 麻豆91在线看| 精品在线观看视频| 久草中文综合在线| 精品一区二区三区影院在线午夜| 亚洲精品视频在线看| 亚洲精品国产一区二区精华液 | 欧美午夜电影在线播放| 欧美中文字幕一二三区视频| 99精品久久久久久| 色综合久久天天| 91官网在线观看| 欧美三级日韩在线| 欧美一二三区在线观看| 欧美一区三区四区| 欧美成人女星排名| 国产日韩欧美高清| 亚洲精选视频在线| 日韩av网站在线观看| 国内精品免费**视频| 粉嫩一区二区三区性色av| 成人免费av网站| 欧美性感一类影片在线播放| 日韩一区二区三区电影| 久久综合色之久久综合| 亚洲国产精品精华液2区45| 中文字幕在线一区免费| 一区二区成人在线观看| 婷婷激情综合网| 国产传媒欧美日韩成人| 91久久人澡人人添人人爽欧美| 欧美精品免费视频| 久久久亚洲欧洲日产国码αv| 1区2区3区欧美| 日本强好片久久久久久aaa| 丰满亚洲少妇av| 欧美精品亚洲一区二区在线播放| 精品少妇一区二区三区在线播放| 国产精品欧美极品| 婷婷综合五月天| 国产成人99久久亚洲综合精品| 欧美最新大片在线看| 337p粉嫩大胆色噜噜噜噜亚洲| 亚洲蜜臀av乱码久久精品蜜桃| 日韩av中文字幕一区二区| 成人av资源在线观看| 91.com视频| 最新国产精品久久精品| 秋霞成人午夜伦在线观看| 成人性视频免费网站| 51精品视频一区二区三区| 日本一区二区成人| 青青草国产精品亚洲专区无| 99精品一区二区三区| 日韩精品自拍偷拍| 亚洲一区二区av电影| 国产寡妇亲子伦一区二区| 91麻豆精品国产91| 亚洲色图都市小说| 国产传媒久久文化传媒| 日韩欧美一区在线| 亚洲自拍偷拍欧美| 97精品久久久午夜一区二区三区 | 欧美一区二区福利在线| 中文字幕制服丝袜成人av| 久久精品72免费观看| 欧美在线综合视频| 国产精品灌醉下药二区| 国产一区二区久久| 欧美一级黄色录像| 五月天精品一区二区三区| 色综合久久中文综合久久牛| 久久综合给合久久狠狠狠97色69| 丝袜诱惑亚洲看片| 欧美色图在线观看| 综合久久综合久久| av在线一区二区| 国产精品免费看片| 成人看片黄a免费看在线| 久久久亚洲精品一区二区三区| 日韩电影免费在线| 欧美日韩激情一区二区三区| 亚洲精品大片www| 色婷婷精品久久二区二区蜜臀av| 国产精品久久夜| 成人久久18免费网站麻豆| 国产欧美日韩综合精品一区二区 | 亚洲男人的天堂在线观看| 成人精品免费视频| 国产午夜精品理论片a级大结局| 九九热在线视频观看这里只有精品| 日韩一区二区三区免费看| 奇米精品一区二区三区在线观看一| 欧美日韩在线播放三区| 亚洲成av人影院| 91精品婷婷国产综合久久竹菊| 蜜臀av性久久久久蜜臀av麻豆| 欧美一区二区视频网站| 日本欧美久久久久免费播放网| 91精品国产综合久久国产大片| 麻豆免费看一区二区三区| 亚洲精品一区二区在线观看| 国产精品99久久久久久似苏梦涵| 国产日产精品1区| 成人av电影在线| 一区二区三区在线播放| 日本高清无吗v一区| 午夜精彩视频在线观看不卡| 欧美一区二区国产| 国产成人aaa| 亚洲综合免费观看高清完整版在线 | 亚洲小说欧美激情另类| 欧美日韩高清一区二区三区| 秋霞电影网一区二区| 国产亚洲视频系列| 91影视在线播放| 日本不卡视频在线| 久久久精品黄色| 在线日韩一区二区| 美日韩黄色大片| 中文一区一区三区高中清不卡| av亚洲精华国产精华精| 亚洲va欧美va人人爽| 日韩欧美亚洲国产精品字幕久久久| 国产suv一区二区三区88区| 自拍偷在线精品自拍偷无码专区| 欧美精品一二三区| 国产 日韩 欧美大片|