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

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

?? rawrsacipher.java

?? jpeg2000編解碼
?? JAVA
字號:
// $Id: RawRSACipher.java,v 1.1.1.1 2002/08/27 12:32:13 grosbois Exp $//// $Log: RawRSACipher.java,v $// Revision 1.1.1.1  2002/08/27 12:32:13  grosbois// Add cryptix 3.2//// Revision 1.11  2000/08/18 02:32:23  edwin// Oops, wrong check ;)// (surprisingly enough the tests didn;t catch this)//// Revision 1.10  2000/08/17 11:41:00  edwin// java.* -> xjava.*//// Revision 1.9  2000/08/16 17:51:43  edwin// Throw a little more sensible exception when decryption fails and the decrypted// data is one byte longer than it should.//// The code here is a little braindamaged, because it assumes that the first// byte of the plaintext is always zero. If decryption fails due to a wrong key,// this is often not the case, which results in a very weird exception.//// We still throw the original weird ArrayIndexOutOfBoundsException for// compatibility, because that is what the old code throwed, however it does// have a more descriptive message now.//// All of this will be documented in the to be written RSA faq, which details// all peculiarities of the RSA code in cryptix3.//// Revision 1.8  1999/07/12 20:34:21  edwin// renaming java.security.interfaces.RSAPrivateKey and RSAPublicKey to CryptixRSAPrivateKey and CryptixRSAPublicKey. This is one more step to JDK1.2 compatibility.//// Revision 1.7  1997/12/23 23:47:51  raif// *** empty log message ***//// Revision 1.6.1  1997/12/24  raif// + fixed the self-test. now runs OK.// + rewrote the engineUpdate().// + added enginePlaintextBlockSize(), engineCiphertextBlockSize()//   and crippled engineBlockSize(). The rationale is that with//   RSA, the encryption/decryption results usually do not match//   their inputs in term of bit/byte-length.//   This fixes the blockSize bug.//// Revision 1.6  1997/12/22 03:16:33  hopwood// + RawRSACipher framing bug fixed.// + BaseRSAKeyPairGenerator test #2 fixed.//// Revision 1.5  1997/11/23 03:09:18  hopwood// + Mostly documentation changes.//// Revision 1.4  1997/11/20 19:46:57  hopwood// + cryptix.util.* name changes.//// Revision 1.3.1  1997/11/18  David Hopwood// + Use BI.dumpString to print parameters in test method.// + Fixed bug in test method (wrong value for e was being displayed).//// Revision 1.3  1997/11/05 16:48:03  raif// *** empty log message ***//// Revision 1.2  1997/11/04 19:33:31  raif// *** empty log message ***//// Revision 1.1.1.1  1997/11/03 22:36:56  hopwood// + Imported to CVS (tagged as 'start').//// Revision 0.1.1.1  1997/08/27  David Hopwood// + Misc. fixes.//// Revision 0.1.1.0  1997/08/23  David Hopwood// + Changed to use the RSA interfaces from java.security.*, rather//   than requiring a particular key class.// + Plaintext and ciphertext block sizes are now equal; we throw a//   CryptixException if a BigInteger to be encrypted is out of range.// + Use the RSA implementation from the RSAAlgorithm class.// + Use new debugging conventions.//// Revision 0.1.0.0  1997/07/24  R. Naffah// + Original version.//// $Endlog$/* * Copyright (c) 1997 Systemics Ltd * on behalf of the Cryptix Development Team.  All rights reserved. */package cryptix.provider.rsa;import cryptix.util.core.Debug;import cryptix.CryptixException;import cryptix.util.core.ArrayUtil;import cryptix.util.core.Hex;import cryptix.util.core.BI;import java.io.PrintWriter;import java.math.BigInteger;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.interfaces.RSAKey;import xjava.security.interfaces.CryptixRSAPublicKey;import xjava.security.interfaces.CryptixRSAPrivateKey;import xjava.security.interfaces.RSAFactors;import java.security.SecureRandom;import java.security.KeyPair;import java.security.KeyPairGenerator;/** * The raw RSA encryption algorithm, without any block framing. * <p> * If the number of bits in the modulus is <i>bitlength</i>, the plaintext and * ciphertext block sizes will both be <code>(int) ((bitlength+7)/8)</code>. * When in ENCRYPT mode, if the value of any plaintext block, considered as a * BigInteger with Big-Endian byte order, is greater than or equal to the * modulus, a CryptixException will be thrown. * <p> * This class is designed to allow any input to the RSA encryption algorithm, * in order to facilitate implementation of standards which use a block framing * format not otherwise supported by Cryptix. Note that using raw RSA directly on * application data is potentially insecure; wherever possible a higher level * algorithm such as "RSA/PKCS#1" should be used. * <p> * (Note: RSA/PKCS#1 is not implemented in this version of Cryptix.) * <p> * <b>References:</b> * <ol> *   <li> <a href="mailto:schneier@counterpane.com">Bruce Schneier</a>, *        "Section 19.3 RSA," *        <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  Raif S. Naffah * @author  David Hopwood * @since   Cryptix 2.2.2 */public class RawRSACipherextends Cipherimplements AsymmetricCipher, Cloneable{// Debugging methods and vars.//...........................................................................    private static final boolean DEBUG = Debug.GLOBAL_DEBUG;    private static final int debuglevel =        DEBUG ? Debug.getLevel("RSA", "RawRSACipher") : 0;    private static final PrintWriter err = DEBUG ? Debug.getOutput() : null;    private static void debug(String s) { err.println("RawRSACipher: " + s); }// RSA constants and variables//...........................................................................    /** true if temporary arrays should be wiped immediately. */    private static final boolean WIPE = true;    private static final int POSITIVE = 1;    private static final BigInteger ZERO = BigInteger.valueOf(0L);    private static final BigInteger ONE =  BigInteger.valueOf(1L);    private BigInteger n;    private BigInteger exp; // e if state is ENCRYPT, d if DECRYPT.    private BigInteger p;   // null if the factors of n are unknown.    private BigInteger q;    private BigInteger u;    private int blockSize; // defaults to 0    private byte[] temp;// Constructor//............................................................................    /**     * Constructs a RawRSA cipher object, in the UNINITIALIZED state.     * This calls the Cipher constructor with <i>implBuffering</i> false,     * <i>implPadding</i> false and the provider set to "Cryptix".     */    public RawRSACipher() {        super(false, false, "Cryptix");    }// JCE methods//............................................................................    /**     * <b>SPI:</b> Initializes this cipher object for encryption, using the     * given public key.     *     * @param  key  the public key to be used for encryption.     * @exception InvalidKeyException if the key class does not implement     *              java.security.interfaces.RSAPublicKey.     */    protected void engineInitEncrypt(Key key)    throws InvalidKeyException {        if (!(key instanceof CryptixRSAPublicKey))            throw new InvalidKeyException(getAlgorithm() +                ": Not an RSA public key");        CryptixRSAPublicKey rsa = (CryptixRSAPublicKey) key;        n = rsa.getModulus();        exp = rsa.getExponent();        if (key instanceof RSAFactors) {            RSAFactors factors = (RSAFactors) key;            p = factors.getP();            q = factors.getQ();            u = factors.getInverseOfQModP();        }        initInternal();    }    /**     * <b>SPI:</b> Initializes this cipher object for decryption, using the     * given private key.     *     * @param  key  the private key to be used for decryption.     * @exception InvalidKeyException if the key class does not implement     *              java.security.interfaces.RSAPrivateKey.     */    protected void engineInitDecrypt(Key key)    throws InvalidKeyException {        if (!(key instanceof CryptixRSAPrivateKey))            throw new InvalidKeyException(getAlgorithm() +                ": Not an RSA private key");        CryptixRSAPrivateKey rsa = (CryptixRSAPrivateKey) key;        n = rsa.getModulus();        exp = rsa.getExponent();        if (key instanceof RSAFactors) {            RSAFactors factors = (RSAFactors) key;            p = factors.getP();            q = factors.getQ();            u = factors.getInverseOfQModP();        }        initInternal();    }    private void initInternal() {//        blockSize = (n.bitLength()+7)/8;        blockSize = BI.getMagnitude(n).length;        temp = new byte[blockSize];    }    /**     * <b>SPI</b>: Return the block size, in bytes. For RawRSA this is the number     * of bytes needed to represent the modulus, <i>n</i>.     *     * @return the block size in bytes.     * @exception CryptixException if the cipher object is uninitialized.     *///    protected int engineBlockSize() {//        if (blockSize == 0) throw new CryptixException(getAlgorithm() +//            ": Block size is not valid until key is set");//        return blockSize;//    }        protected int enginePlaintextBlockSize () {        if (blockSize == 0) throw new CryptixException(getAlgorithm() +            ": Block size is not valid until key is set");        return blockSize - 1;    }        protected int engineCiphertextBlockSize() {        if (blockSize == 0) throw new CryptixException(getAlgorithm() +            ": Block size is not valid until key is set");        return blockSize;    }    protected int engineUpdate(byte[] in, int inOffset, int inLen,                               byte[] out, int outOffset) {/*if (DEBUG && debuglevel >= 7) debug("in.length = " + in.length + ", out.length = " + out.length + ", blockSize = " + blockSize);        for (int i = 0; i <= inLen-blockSize; i += blockSize) {if (DEBUG && debuglevel >= 8) debug("i = " + i);            System.arraycopy(in, inOffset+i, temp, 0, blockSize);            BigInteger I = new BigInteger(POSITIVE, temp);            if (I.compareTo(n) >= 0) throw new CryptixException(getAlgorithm() +                ": Input block value is out of range (>= modulus)");            BigInteger O = RSAAlgorithm.rsa(I, n, exp, p, q, u);            byte[] buffer = O.toByteArray();            int displacement = blockSize-buffer.length;            if (displacement > 0) {                ArrayUtil.clear(out, outOffset+i, displacement);                System.arraycopy(buffer, 0, out, outOffset+i+displacement, buffer.length);            } else {                System.arraycopy(buffer, -displacement, out, outOffset+i, blockSize);            }            if (WIPE) ArrayUtil.clear(buffer);        }        if (WIPE) ArrayUtil.clear(temp);        return blockSize;*/        if (inLen < 0) throw new IllegalArgumentException("inLen < 0");        int inBlockSize = getState() == ENCRYPT ?            enginePlaintextBlockSize() : engineCiphertextBlockSize();        int outBlockSize = getState() == ENCRYPT ?            engineCiphertextBlockSize() : enginePlaintextBlockSize();        int blockCount = inLen / inBlockSize;        for (int i = 0; i < blockCount; i++) {            ArrayUtil.clear(temp);            System.arraycopy(in, inOffset, temp, temp.length - inBlockSize, inBlockSize);            BigInteger I = new BigInteger(POSITIVE, temp);            if (I.compareTo(n) >= 0) throw new CryptixException(getAlgorithm() +                ": Input block value is out of range (>= modulus)");            BigInteger O = RSAAlgorithm.rsa(I, n, exp, p, q, u);            byte[] buffer = BI.getMagnitude(O);            if (buffer.length > outBlockSize) {                throw new ArrayIndexOutOfBoundsException("Decryption failed, "+                                                         "wrong key?");            }            ArrayUtil.clear(temp);            System.arraycopy(buffer, 0, temp, outBlockSize - buffer.length, buffer.length);            System.arraycopy(temp, 0, out, outOffset, outBlockSize);            inOffset += inBlockSize;            outOffset += outBlockSize;        }        return blockCount * outBlockSize;    }// 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 Exception {        KeyPairGenerator keygen = KeyPairGenerator.getInstance("RSA", "Cryptix");        SecureRandom random = new SecureRandom();        long start = System.currentTimeMillis();        keygen.initialize(1024, random);        KeyPair keypair = keygen.generateKeyPair();        long duration = System.currentTimeMillis() - start;        out.println("Keygen: " + (float)duration/1000 + " seconds");        RawRSACipher raw = new RawRSACipher();        raw.test(out, keypair, random);    }    private void test(PrintWriter out, KeyPair keypair, SecureRandom random)    throws KeyException {        CryptixRSAPrivateKey privateKey = (CryptixRSAPrivateKey) (keypair.getPrivate());        CryptixRSAPublicKey publicKey = (CryptixRSAPublicKey) (keypair.getPublic());//        byte[] M = new byte[blockSize()];//        random.nextBytes(M);        long start = System.currentTimeMillis();        initEncrypt(publicKey);        BigInteger e = exp;                byte[] M = new byte[getPlaintextBlockSize()];        random.nextBytes(M);                byte[] C = crypt(M);        long midpoint = System.currentTimeMillis();        initDecrypt(privateKey);        byte[] Mdash = crypt(C);        long end = System.currentTimeMillis();        out.println("         n = " + BI.dumpString(n));        out.println("         e = " + BI.dumpString(e));        out.println("         d = " + BI.dumpString(exp));        out.println("         p = " + BI.dumpString(p));        out.println("         q = " + BI.dumpString(q));        out.println("q^-1 mod p = " + BI.dumpString(u));        out.println(" plaintext = " + Hex.toString(M) + "\n");        out.println("ciphertext = " + Hex.toString(C) + "\n");        if (!ArrayUtil.areEqual(M, Mdash)) {            out.println("DECRYPTION FAILED!\n");            out.println("  computed = " + Hex.toString(Mdash) + "\n");        }        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一区二区三区免费野_久草精品视频
欧美一区二区三区思思人| 国产成a人亚洲精| 亚洲品质自拍视频网站| 久久这里都是精品| 日韩三区在线观看| 91精品国产全国免费观看| 欧美日韩一区二区三区四区| 精品1区2区3区| 欧美老女人第四色| 欧美日本在线观看| 欧美一区二区视频在线观看| 欧美成人猛片aaaaaaa| 精品福利在线导航| 国产欧美日韩激情| 亚洲欧美电影一区二区| 亚洲蜜臀av乱码久久精品蜜桃| 洋洋成人永久网站入口| 亚洲成人高清在线| 国内久久精品视频| www.亚洲激情.com| 欧洲一区二区av| 欧美日韩极品在线观看一区| 日韩欧美电影在线| 亚洲国产激情av| 一区二区三区色| 免费美女久久99| 国产成人午夜片在线观看高清观看| 风间由美一区二区三区在线观看| 91在线一区二区三区| 欧美日韩国产精选| 久久久久国产免费免费| 亚洲激情第一区| 老司机免费视频一区二区| 国产福利一区二区三区视频| 91免费版在线看| 欧美电视剧在线观看完整版| 中文字幕一区二区三| 日本少妇一区二区| www.日韩精品| 欧美一卡二卡在线| 亚洲欧洲av色图| 精品亚洲成a人| 欧美日韩国产欧美日美国产精品| 国产欧美一区二区精品秋霞影院| 亚洲一区二区三区四区中文字幕| 极品美女销魂一区二区三区| 91久久久免费一区二区| 久久精品亚洲麻豆av一区二区 | 激情五月激情综合网| 91亚洲资源网| 国产欧美一区二区三区鸳鸯浴 | 亚洲第一久久影院| 久久精工是国产品牌吗| 在线免费观看日本欧美| 国产欧美一区二区精品性| 美女网站在线免费欧美精品| 色综合视频一区二区三区高清| 精品国免费一区二区三区| 亚洲无线码一区二区三区| 99re66热这里只有精品3直播 | 三级成人在线视频| 99精品欧美一区| 欧美激情在线一区二区| 激情另类小说区图片区视频区| 欧美日韩一区小说| 成人免费一区二区三区在线观看| 韩国av一区二区三区在线观看| 欧美日韩国产一级二级| 亚洲线精品一区二区三区八戒| 成人深夜在线观看| 国产性色一区二区| 国内久久精品视频| 久久老女人爱爱| 国产精品资源网站| 国产午夜精品在线观看| 国产在线播放一区| 国产日韩欧美精品综合| 国产成人在线观看| 国产偷v国产偷v亚洲高清| 国产精品亚洲一区二区三区妖精| 精品久久人人做人人爽| 久久国产乱子精品免费女| 日韩欧美一卡二卡| 国内精品国产成人国产三级粉色| 欧美不卡一二三| 国产成人在线视频网址| 国产精品美女久久久久av爽李琼| 成人国产免费视频| 亚洲激情中文1区| 91九色最新地址| 五月婷婷综合在线| 欧美v亚洲v综合ⅴ国产v| 国产真实乱对白精彩久久| 久久久三级国产网站| eeuss鲁片一区二区三区在线看| 国产精品夫妻自拍| 欧美图片一区二区三区| 日本成人在线网站| 久久精品人人爽人人爽| 99精品热视频| 日本91福利区| 中文一区二区在线观看| 色婷婷精品久久二区二区蜜臂av | 日韩精品中文字幕一区二区三区| 国产一区二区中文字幕| 亚洲品质自拍视频网站| 4hu四虎永久在线影院成人| 国产一区二区三区久久悠悠色av| 国产精品久久久久永久免费观看| 欧美三级欧美一级| 国产黄色精品网站| 亚洲午夜影视影院在线观看| 精品久久久久久久久久久久久久久久久| 国产91丝袜在线观看| 亚洲国产综合色| 国产精品免费观看视频| 欧美日韩成人综合天天影院| 国产69精品久久久久毛片| 亚洲一区二区三区中文字幕在线| 精品久久久影院| 在线亚洲+欧美+日本专区| 久久精品99久久久| 亚洲一区二区在线观看视频| 久久久精品免费网站| 欧美顶级少妇做爰| 91亚洲精品乱码久久久久久蜜桃 | 国产欧美一区二区精品秋霞影院| 欧美性大战久久久久久久| 国产成人h网站| 麻豆精品视频在线观看免费| 亚洲婷婷国产精品电影人久久| 精品久久久久一区| 欧美高清视频不卡网| 99精品视频一区二区| 国产一区福利在线| 久久99精品久久久| 午夜不卡av在线| 亚洲综合色自拍一区| 国产精品久久久久aaaa樱花 | 一区二区三区日韩欧美精品 | 欧美性videosxxxxx| 97久久久精品综合88久久| 国产精品性做久久久久久| 日本欧美加勒比视频| 亚洲国产精品一区二区www| 亚洲天堂精品视频| 亚洲天堂福利av| 日韩毛片高清在线播放| 国产精品久久久99| 国产精品福利一区二区三区| 国产精品三级电影| 久久精品夜夜夜夜久久| 久久精品夜色噜噜亚洲aⅴ| 久久影院电视剧免费观看| 精品精品欲导航| 精品人伦一区二区色婷婷| 亚洲精品一区在线观看| 久久伊人中文字幕| 久久精品男人的天堂| 国产网红主播福利一区二区| 国产精品无人区| 国产精品福利一区| 亚洲精选免费视频| 亚洲一区二区视频在线观看| 污片在线观看一区二区| 男女激情视频一区| 国产在线精品一区二区夜色| 国产毛片一区二区| 99国产精品久久久久| 色狠狠桃花综合| 欧美丰满美乳xxx高潮www| 欧美一区二区三区四区在线观看 | 色天使久久综合网天天| 欧美伊人久久大香线蕉综合69 | 亚洲日本va午夜在线影院| 亚洲精品中文在线| 亚洲成年人网站在线观看| 麻豆精品蜜桃视频网站| 国产福利一区二区三区视频在线| 99精品欧美一区| 欧美精品亚洲一区二区在线播放| 日韩色视频在线观看| 国产精品对白交换视频 | 国精产品一区一区三区mba视频| 国产伦精品一区二区三区在线观看| 国产成人在线观看免费网站| 欧美影院午夜播放| wwwwxxxxx欧美| 一区二区三区四区精品在线视频 | 久久亚洲综合av| 中文字幕综合网| 奇米一区二区三区| 99国产精品国产精品久久| 日韩一区二区免费视频| 国产日韩精品一区| 日韩一区精品字幕| 成人sese在线| 精品久久久久99| 天涯成人国产亚洲精品一区av| 国产精品一卡二卡在线观看|