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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? rc2wrapengine.java

?? 內(nèi)容:基于jdk1.4的加密算法的具體實(shí)現(xiàn)
?? JAVA
字號(hào):
package org.bouncycastle.crypto.engines;import java.security.SecureRandom;import org.bouncycastle.crypto.CipherParameters;import org.bouncycastle.crypto.Digest;import org.bouncycastle.crypto.InvalidCipherTextException;import org.bouncycastle.crypto.Wrapper;import org.bouncycastle.crypto.digests.SHA1Digest;import org.bouncycastle.crypto.modes.CBCBlockCipher;import org.bouncycastle.crypto.params.ParametersWithIV;import org.bouncycastle.crypto.params.ParametersWithRandom;/** * Wrap keys according to RFC 3217 - RC2 mechanism */public class RC2WrapEngine    implements Wrapper{   /** Field engine */   private CBCBlockCipher engine;   /** Field param */   private CipherParameters param;   /** Field paramPlusIV */   private ParametersWithIV paramPlusIV;   /** Field iv */   private byte[] iv;   /** Field forWrapping */   private boolean forWrapping;      private SecureRandom sr;   /** Field IV2           */   private static final byte[] IV2 = { (byte) 0x4a, (byte) 0xdd, (byte) 0xa2,                                       (byte) 0x2c, (byte) 0x79, (byte) 0xe8,                                       (byte) 0x21, (byte) 0x05 };    //    // checksum digest    //    Digest  sha1 = new SHA1Digest();    byte[]  digest = new byte[20];   /**    * Method init    *    * @param forWrapping    * @param param    */   public void init(boolean forWrapping, CipherParameters param)   {        this.forWrapping = forWrapping;        this.engine = new CBCBlockCipher(new RC2Engine());        if (param instanceof ParametersWithRandom)        {            ParametersWithRandom pWithR = (ParametersWithRandom)param;            sr = pWithR.getRandom();            param = pWithR.getParameters();        }        else        {            sr = new SecureRandom();        }                if (param instanceof ParametersWithIV)        {            this.paramPlusIV = (ParametersWithIV)param;            this.iv = this.paramPlusIV.getIV();            this.param = this.paramPlusIV.getParameters();            if (this.forWrapping)            {                if ((this.iv == null) || (this.iv.length != 8))                {                    throw new IllegalArgumentException("IV is not 8 octets");                }            }            else            {                throw new IllegalArgumentException(                        "You should not supply an IV for unwrapping");            }        }        else        {            this.param = param;            if (this.forWrapping)            {                // Hm, we have no IV but we want to wrap ?!?                // well, then we have to create our own IV.                this.iv = new byte[8];                sr.nextBytes(iv);                this.paramPlusIV = new ParametersWithIV(this.param, this.iv);            }        }   }   /**    * Method getAlgorithmName    *    * @return the algorithm name "RC2".    */   public String getAlgorithmName()    {      return "RC2";   }   /**    * Method wrap    *    * @param in    * @param inOff    * @param inLen    * @return the wrapped bytes.    */   public byte[] wrap(byte[] in, int inOff, int inLen)    {        if (!forWrapping)        {            throw new IllegalStateException("Not initialized for wrapping");        }        int length = inLen + 1;        if ((length % 8) != 0)        {            length += 8 - (length % 8);        }        byte keyToBeWrapped[] = new byte[length];        keyToBeWrapped[0] = (byte)inLen;        System.arraycopy(in, inOff, keyToBeWrapped, 1, inLen);                byte[] pad = new byte[keyToBeWrapped.length - inLen - 1];        if (pad.length > 0)        {            sr.nextBytes(pad);            System.arraycopy(pad, 0, keyToBeWrapped, inLen + 1, pad.length);        }        // Compute the CMS Key Checksum, (section 5.6.1), call this CKS.        byte[] CKS = calculateCMSKeyChecksum(keyToBeWrapped);        // Let WKCKS = WK || CKS where || is concatenation.        byte[] WKCKS = new byte[keyToBeWrapped.length + CKS.length];        System.arraycopy(keyToBeWrapped, 0, WKCKS, 0, keyToBeWrapped.length);        System.arraycopy(CKS, 0, WKCKS, keyToBeWrapped.length, CKS.length);        // Encrypt WKCKS in CBC mode using KEK as the key and IV as the        // initialization vector. Call the results TEMP1.        byte TEMP1[] = new byte[WKCKS.length];        System.arraycopy(WKCKS, 0, TEMP1, 0, WKCKS.length);        int noOfBlocks = WKCKS.length / engine.getBlockSize();        int extraBytes = WKCKS.length % engine.getBlockSize();        if (extraBytes != 0)        {            throw new IllegalStateException("Not multiple of block length");        }        engine.init(true, paramPlusIV);        for (int i = 0; i < noOfBlocks; i++)        {            int currentBytePos = i * engine.getBlockSize();            engine.processBlock(TEMP1, currentBytePos, TEMP1, currentBytePos);        }        // Left TEMP2 = IV || TEMP1.        byte[] TEMP2 = new byte[this.iv.length + TEMP1.length];        System.arraycopy(this.iv, 0, TEMP2, 0, this.iv.length);        System.arraycopy(TEMP1, 0, TEMP2, this.iv.length, TEMP1.length);        // Reverse the order of the octets in TEMP2 and call the result TEMP3.        byte[] TEMP3 = new byte[TEMP2.length];        for (int i = 0; i < TEMP2.length; i++)        {            TEMP3[i] = TEMP2[TEMP2.length - (i + 1)];        }        // Encrypt TEMP3 in CBC mode using the KEK and an initialization vector        // of 0x 4a dd a2 2c 79 e8 21 05. The resulting cipher text is the        // desired        // result. It is 40 octets long if a 168 bit key is being wrapped.        ParametersWithIV param2 = new ParametersWithIV(this.param, IV2);        this.engine.init(true, param2);        for (int i = 0; i < noOfBlocks + 1; i++)        {            int currentBytePos = i * engine.getBlockSize();            engine.processBlock(TEMP3, currentBytePos, TEMP3, currentBytePos);        }        return TEMP3;   }   /**    * Method unwrap    *    * @param in    * @param inOff    * @param inLen    * @return the unwrapped bytes.    * @throws InvalidCipherTextException    */   public byte[] unwrap(byte[] in, int inOff, int inLen)            throws InvalidCipherTextException    {        if (forWrapping)        {            throw new IllegalStateException("Not set for unwrapping");        }        if (in == null)        {            throw new InvalidCipherTextException("Null pointer as ciphertext");        }        if (inLen % engine.getBlockSize() != 0)        {            throw new InvalidCipherTextException("Ciphertext not multiple of "                    + engine.getBlockSize());        }        /*         * // Check if the length of the cipher text is reasonable given the key //         * type. It must be 40 bytes for a 168 bit key and either 32, 40, or //         * 48 bytes for a 128, 192, or 256 bit key. If the length is not         * supported // or inconsistent with the algorithm for which the key is         * intended, // return error. // // we do not accept 168 bit keys. it         * has to be 192 bit. int lengthA = (estimatedKeyLengthInBit / 8) + 16;         * int lengthB = estimatedKeyLengthInBit % 8;         *          * if ((lengthA != keyToBeUnwrapped.length) || (lengthB != 0)) { throw         * new XMLSecurityException("empty"); }         */        // Decrypt the cipher text with TRIPLedeS in CBC mode using the KEK        // and an initialization vector (IV) of 0x4adda22c79e82105. Call the        // output TEMP3.        ParametersWithIV param2 = new ParametersWithIV(this.param, IV2);        this.engine.init(false, param2);        byte TEMP3[] = new byte[inLen];        System.arraycopy(in, inOff, TEMP3, 0, inLen);        for (int i = 0; i < (TEMP3.length / engine.getBlockSize()); i++)        {            int currentBytePos = i * engine.getBlockSize();            engine.processBlock(TEMP3, currentBytePos, TEMP3, currentBytePos);        }        // Reverse the order of the octets in TEMP3 and call the result TEMP2.        byte[] TEMP2 = new byte[TEMP3.length];        for (int i = 0; i < TEMP3.length; i++)        {            TEMP2[i] = TEMP3[TEMP3.length - (i + 1)];        }        // Decompose TEMP2 into IV, the first 8 octets, and TEMP1, the remaining        // octets.        this.iv = new byte[8];        byte[] TEMP1 = new byte[TEMP2.length - 8];        System.arraycopy(TEMP2, 0, this.iv, 0, 8);        System.arraycopy(TEMP2, 8, TEMP1, 0, TEMP2.length - 8);        // Decrypt TEMP1 using TRIPLedeS in CBC mode using the KEK and the IV        // found in the previous step. Call the result WKCKS.        this.paramPlusIV = new ParametersWithIV(this.param, this.iv);        this.engine.init(false, this.paramPlusIV);        byte[] LCEKPADICV = new byte[TEMP1.length];        System.arraycopy(TEMP1, 0, LCEKPADICV, 0, TEMP1.length);        for (int i = 0; i < (LCEKPADICV.length / engine.getBlockSize()); i++)        {            int currentBytePos = i * engine.getBlockSize();            engine.processBlock(LCEKPADICV, currentBytePos, LCEKPADICV,                    currentBytePos);        }        // Decompose LCEKPADICV. CKS is the last 8 octets and WK, the wrapped        // key, are        // those octets before the CKS.        byte[] result = new byte[LCEKPADICV.length - 8];        byte[] CKStoBeVerified = new byte[8];        System.arraycopy(LCEKPADICV, 0, result, 0, LCEKPADICV.length - 8);        System.arraycopy(LCEKPADICV, LCEKPADICV.length - 8, CKStoBeVerified, 0,                8);        // Calculate a CMS Key Checksum, (section 5.6.1), over the WK and        // compare        // with the CKS extracted in the above step. If they are not equal,        // return error.        if (!checkCMSKeyChecksum(result, CKStoBeVerified))        {            throw new InvalidCipherTextException(                    "Checksum inside ciphertext is corrupted");        }        if ((result.length - ((result[0] & 0xff) + 1)) > 7)        {            throw new InvalidCipherTextException("too many pad bytes ("                    + (result.length - ((result[0] & 0xff) + 1)) + ")");        }        // CEK is the wrapped key, now extracted for use in data decryption.        byte[] CEK = new byte[result[0]];        System.arraycopy(result, 1, CEK, 0, CEK.length);        return CEK;    }    /**     * Some key wrap algorithms make use of the Key Checksum defined     * in CMS [CMS-Algorithms]. This is used to provide an integrity     * check value for the key being wrapped. The algorithm is     *     * - Compute the 20 octet SHA-1 hash on the key being wrapped.     * - Use the first 8 octets of this hash as the checksum value.     *     * @param key     * @return     * @throws RuntimeException     * @see http://www.w3.org/TR/xmlenc-core/#sec-CMSKeyChecksum     */    private byte[] calculateCMSKeyChecksum(        byte[] key)    {        byte[]  result = new byte[8];        sha1.update(key, 0, key.length);        sha1.doFinal(digest, 0);        System.arraycopy(digest, 0, result, 0, 8);        return result;    }    /**     * @param key     * @param checksum     * @return     * @see http://www.w3.org/TR/xmlenc-core/#sec-CMSKeyChecksum     */    private boolean checkCMSKeyChecksum(        byte[] key,        byte[] checksum)    {        byte[] calculatedChecksum = calculateCMSKeyChecksum(key);        if (checksum.length != calculatedChecksum.length)        {            return false;        }        for (int i = 0; i != checksum.length; i++)        {            if (checksum[i] != calculatedChecksum[i])            {                return false;            }        }        return true;    }}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产资源在线一区| 视频一区视频二区中文字幕| 国产精品996| 久久久美女毛片| 成人福利视频网站| 亚洲欧美日韩电影| 欧美日韩一本到| 午夜婷婷国产麻豆精品| 免费精品视频在线| 久久久欧美精品sm网站| 亚洲综合丝袜美腿| 欧美日韩午夜精品| 99精品1区2区| 亚洲午夜久久久久| 精品久久一区二区| 99久久精品一区二区| 亚洲国产日韩a在线播放| 欧美成人一区二区三区在线观看| 国产 欧美在线| 亚洲综合免费观看高清完整版 | 国产精品久久久久久久浪潮网站| 99久久99久久久精品齐齐| 五月激情综合色| 亚洲国产高清不卡| 337p亚洲精品色噜噜噜| 国产大陆亚洲精品国产| 亚洲线精品一区二区三区| 26uuu精品一区二区在线观看| 成人免费毛片片v| 天堂久久久久va久久久久| 国产日韩亚洲欧美综合| 欧美日本一区二区在线观看| 国产在线精品一区二区| 亚洲国产三级在线| 国产精品免费久久| 日韩三区在线观看| 欧美在线|欧美| 国产高清精品在线| 日韩黄色免费网站| 一区二区三区中文在线观看| 精品美女被调教视频大全网站| 成人丝袜18视频在线观看| 视频一区国产视频| 亚洲色图欧美偷拍| 久久精品视频免费| 在线成人av影院| 欧日韩精品视频| 成人一道本在线| 国产一区二区主播在线| 日韩专区在线视频| 亚洲一区二区综合| 中文字幕一区二区日韩精品绯色| 日韩视频免费观看高清在线视频| 欧美综合亚洲图片综合区| 粉嫩一区二区三区性色av| 青草av.久久免费一区| 亚洲最大的成人av| 亚洲另类春色国产| 国产精品国产三级国产有无不卡| 欧美mv和日韩mv的网站| 欧美裸体一区二区三区| 在线免费观看成人短视频| 成人av片在线观看| 成人国产亚洲欧美成人综合网| 精品中文字幕一区二区| 日韩成人av影视| 丝袜国产日韩另类美女| 亚洲一级二级在线| 亚洲尤物在线视频观看| 一区二区三区视频在线看| 亚洲欧美激情一区二区| 中文字幕在线一区免费| 国产精品久久毛片a| 中文子幕无线码一区tr| 欧美国产成人在线| 国产精品午夜电影| 国产精品美女久久久久aⅴ| 国产午夜三级一区二区三| 久久久精品免费网站| 日本一区免费视频| 中文字幕在线不卡视频| 综合久久给合久久狠狠狠97色 | 日韩手机在线导航| 日韩免费视频一区| 337p日本欧洲亚洲大胆色噜噜| 精品成人在线观看| 国产三级精品三级| 中文字幕一区二区三区蜜月 | 久久精品人人做人人爽人人| 久久久久成人黄色影片| 国产精品无人区| 一区二区三区精品| 日韩精品一区第一页| 狠狠色2019综合网| 成人免费毛片嘿嘿连载视频| 91视频在线看| 欧美日韩中文精品| 欧美成人一区二区| 国产精品伦理在线| 亚洲综合精品自拍| 激情综合网av| av电影在线不卡| 欧美精品第1页| 欧美激情一区二区| 一区二区三区精品视频在线| 男女激情视频一区| 成人福利视频在线看| 欧美日韩精品一区二区三区| 日韩欧美亚洲一区二区| 国产精品国产三级国产a| 午夜视黄欧洲亚洲| 国产激情偷乱视频一区二区三区| 91猫先生在线| 精品久久一区二区三区| 亚洲乱码国产乱码精品精98午夜| 日韩成人精品视频| 99精品欧美一区二区三区小说| 91麻豆精品国产91久久久资源速度 | 精品福利一区二区三区免费视频| 国产精品色婷婷久久58| 婷婷久久综合九色国产成人| 国产a区久久久| 91精品国产综合久久久久久久| 亚洲国产精品二十页| 日韩高清在线一区| 日本精品一级二级| 久久精品一区蜜桃臀影院| 三级成人在线视频| 91热门视频在线观看| 26uuu另类欧美| 日日摸夜夜添夜夜添精品视频| 成人小视频在线| 日韩欧美成人激情| 亚洲国产中文字幕在线视频综合| 国产高清不卡一区二区| 欧美一级高清片| 亚洲综合免费观看高清完整版在线 | 欧美videos中文字幕| 亚洲三级电影网站| 国产精品亚洲视频| 欧美va天堂va视频va在线| 亚洲v精品v日韩v欧美v专区| 暴力调教一区二区三区| 国产午夜精品美女毛片视频| 蜜桃在线一区二区三区| 欧美人牲a欧美精品| 怡红院av一区二区三区| 成人97人人超碰人人99| 国产欧美日韩不卡免费| 久久99日本精品| 日韩欧美中文字幕制服| 偷拍亚洲欧洲综合| 欧美男女性生活在线直播观看| 一区二区三区在线观看视频| 成人免费看的视频| 国产精品伦一区| 成人成人成人在线视频| 欧美国产一区视频在线观看| 国产精品18久久久久久久久| 精品福利在线导航| 国产麻豆一精品一av一免费| 精品国精品自拍自在线| 黄色精品一二区| 久久日韩精品一区二区五区| 精品在线观看视频| 欧美精品一区二区三区在线播放| 麻豆精品一区二区av白丝在线| 欧美一级高清大全免费观看| 日本成人中文字幕在线视频| 日韩午夜激情免费电影| 麻豆精品一区二区| 久久一留热品黄| 国产成人精品免费网站| 国产精品天干天干在观线| 99久久er热在这里只有精品15| 亚洲人成影院在线观看| 欧美亚洲国产bt| 奇米综合一区二区三区精品视频| 日韩欧美色电影| 国产精品99久久久久久久女警| 中文av字幕一区| 欧洲亚洲国产日韩| 男女性色大片免费观看一区二区| 精品国产99国产精品| 国产成人亚洲综合a∨猫咪| 国产精品国产三级国产普通话蜜臀| 91免费小视频| 五月激情丁香一区二区三区| 欧美精品一区二区三区视频| 懂色av一区二区三区免费看| 一区二区三区鲁丝不卡| 欧美一区二区精品久久911| 韩国女主播一区| 一区二区在线观看免费视频播放| 欧美老年两性高潮| 国产成人自拍在线| 亚洲国产精品嫩草影院| 欧美一区二区日韩一区二区| 岛国一区二区三区| 亚洲图片欧美综合|