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

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

?? desedewrapengine.java

?? 內容:基于jdk1.4的加密算法的具體實現
?? JAVA
字號:
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.KeyParameter;import org.bouncycastle.crypto.params.ParametersWithIV;/** * Wrap keys according to * <A HREF="http://www.ietf.org/internet-drafts/draft-ietf-smime-key-wrap-01.txt"> * draft-ietf-smime-key-wrap-01.txt</A>. * <p> * Note:  * <ul> * <li>this is based on a draft, and as such is subject to change - don't use this class for anything requiring long term storage. * <li>if you are using this to wrap triple-des keys you need to set the * parity bits on the key and, if it's a two-key triple-des key, pad it * yourself. * </ul> */public class DESedeWrapEngine    implements Wrapper{   /** Field engine */   private CBCBlockCipher engine;   /** Field param */   private KeyParameter param;   /** Field paramPlusIV */   private ParametersWithIV paramPlusIV;   /** Field iv */   private byte[] iv;   /** Field forWrapping */   private boolean forWrapping;   /** 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 DESedeEngine());        if (param instanceof KeyParameter)        {            this.param = (KeyParameter)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];                SecureRandom sr = new SecureRandom();                sr.nextBytes(iv);                this.paramPlusIV = new ParametersWithIV(this.param, this.iv);            }        }        else if (param instanceof ParametersWithIV)        {            this.paramPlusIV = (ParametersWithIV)param;            this.iv = this.paramPlusIV.getIV();            this.param = (KeyParameter)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");            }        }    }   /**    * Method getAlgorithmName    *    * @return the algorithm name "DESede".    */   public String getAlgorithmName()    {      return "DESede";   }   /**    * 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");      }      byte keyToBeWrapped[] = new byte[inLen];      System.arraycopy(in, inOff, keyToBeWrapped, 0, inLen);      // 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[] WKCKS = new byte[TEMP1.length];      System.arraycopy(TEMP1, 0, WKCKS, 0, TEMP1.length);      for (int i = 0; i < (WKCKS.length / engine.getBlockSize()); i++)       {         int currentBytePos = i * engine.getBlockSize();         engine.processBlock(WKCKS, currentBytePos, WKCKS, currentBytePos);      }      // Decompose WKCKS. CKS is the last 8 octets and WK, the wrapped key, are      // those octets before the CKS.      byte[] result = new byte[WKCKS.length - 8];      byte[] CKStoBeVerified = new byte[8];      System.arraycopy(WKCKS, 0, result, 0, WKCKS.length - 8);      System.arraycopy(WKCKS, WKCKS.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");      }      // WK is the wrapped key, now extracted for use in data decryption.      return result;   }    /**     * 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 the CMS checksum.     * @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 true if okay, false otherwise.     * @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;    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产综合视频在线观看| 国产福利一区二区| 97se亚洲国产综合自在线观| 日韩亚洲国产中文字幕欧美| 亚洲靠逼com| 91小视频免费观看| 国产精品三级久久久久三级| 午夜精品成人在线| 在线视频欧美精品| 亚洲欧美电影院| 91视频精品在这里| 亚洲一卡二卡三卡四卡 | 韩国毛片一区二区三区| 精品剧情v国产在线观看在线| 国产精品麻豆欧美日韩ww| 国产aⅴ综合色| 国产欧美日韩卡一| 91网址在线看| 亚洲综合男人的天堂| 欧美日韩成人综合| 蜜臀91精品一区二区三区| 欧美精品一区二区三区蜜桃视频| 国产精品一区二区x88av| 91麻豆精品国产综合久久久久久| 亚洲一区电影777| 日韩免费观看高清完整版| 国产成人精品一区二区三区网站观看| 久久女同精品一区二区| 91啪九色porn原创视频在线观看| 午夜久久久久久| 国产午夜精品理论片a级大结局| gogo大胆日本视频一区| 丝瓜av网站精品一区二区 | 日日噜噜夜夜狠狠视频欧美人| 日韩色视频在线观看| 国产成a人无v码亚洲福利| 久久精品夜夜夜夜久久| 欧美吻胸吃奶大尺度电影| 国v精品久久久网| 国产麻豆精品一区二区| 日韩不卡一二三区| 亚洲一区二区在线免费观看视频| 国产精品高潮久久久久无| 国产亚洲一区二区在线观看| 日韩精品一区二区三区蜜臀| 欧美一区二区久久| 欧美亚洲一区二区在线观看| 99久久精品国产一区| 国产精品亚洲视频| 国产精品 欧美精品| 91丨porny丨首页| 91精品91久久久中77777| 色综合婷婷久久| 欧美色区777第一页| 欧美日韩综合不卡| 日韩一区二区影院| 亚洲精品在线电影| 国产精品色一区二区三区| 亚洲欧洲美洲综合色网| 亚洲视频1区2区| 性久久久久久久久久久久| 美国av一区二区| 高清不卡一区二区| 欧美色图一区二区三区| 日韩免费成人网| 免费一级欧美片在线观看| 国产美女娇喘av呻吟久久| av在线不卡电影| 欧美私人免费视频| 久久夜色精品国产噜噜av| 中文字幕一区二| 久久99久久久久久久久久久| a4yy欧美一区二区三区| 欧美丰满少妇xxxbbb| 国产欧美日韩亚州综合 | 欧美日本乱大交xxxxx| 精品91自产拍在线观看一区| 一区二区三区欧美| 国产经典欧美精品| 欧美成人vps| 午夜亚洲福利老司机| 9i在线看片成人免费| 欧美精彩视频一区二区三区| 午夜久久久久久久久| 91尤物视频在线观看| 久久久蜜桃精品| 久久精品国产一区二区三 | 一本久道中文字幕精品亚洲嫩| 日韩欧美国产麻豆| 日日噜噜夜夜狠狠视频欧美人| 91福利视频久久久久| 亚洲国产岛国毛片在线| 国产在线观看免费一区| 欧美一级免费大片| 日本欧美加勒比视频| 欧美日韩一本到| 一区二区免费视频| 91成人在线精品| 亚洲动漫第一页| 欧美喷潮久久久xxxxx| 亚洲va韩国va欧美va精品| 欧美三级电影网| 国内外成人在线| 国产精品高清亚洲| 在线观看国产一区二区| 天天色综合成人网| 久久精品一二三| 9i在线看片成人免费| 婷婷国产在线综合| 日韩免费高清av| 国产成人av一区| 亚洲综合图片区| 欧美tickling挠脚心丨vk| 国产精品伊人色| 亚洲高清免费一级二级三级| 日韩午夜小视频| 色婷婷国产精品| 精品在线播放午夜| 亚洲靠逼com| 国产视频一区在线观看| 欧美在线影院一区二区| 久久成人综合网| 亚洲一区在线观看免费观看电影高清| 亚洲精品一区二区三区99| 91视频一区二区三区| 久久精品国产久精国产爱| 一区二区成人在线| 亚洲国产精品成人综合色在线婷婷 | 国产精品污污网站在线观看| 欧美吻胸吃奶大尺度电影| 成人97人人超碰人人99| 久久91精品国产91久久小草| 亚洲主播在线播放| 中文字幕一区二区三区在线不卡| 日韩欧美国产精品| 777久久久精品| 欧美日韩一区二区在线观看视频| 不卡免费追剧大全电视剧网站| 国产一区不卡在线| 黄网站免费久久| 久久精品国产亚洲高清剧情介绍 | 欧美中文字幕一区| 91一区二区在线| 91蜜桃在线免费视频| 不卡的av中国片| 97精品视频在线观看自产线路二| www.欧美日韩国产在线| 成人综合日日夜夜| 一本大道久久a久久综合| 99久久99久久精品免费看蜜桃| 99久久免费视频.com| 97精品久久久午夜一区二区三区 | 另类小说综合欧美亚洲| 香蕉乱码成人久久天堂爱免费| 亚洲乱码一区二区三区在线观看| 国产精品视频yy9299一区| 日韩精品一区二区三区在线观看| 色美美综合视频| 97精品久久久午夜一区二区三区| 国产麻豆成人精品| 国产中文字幕一区| 亚洲高清不卡在线| 午夜精品一区二区三区电影天堂| 亚洲欧洲韩国日本视频| 亚洲欧美视频一区| 成人欧美一区二区三区小说| 亚洲天堂av老司机| 久久久久久久国产精品影院| 精品蜜桃在线看| 精品粉嫩超白一线天av| 久久久久久久久久久电影| 久久午夜电影网| 国产亚洲一区二区三区| 国产欧美日本一区视频| 中文字幕在线一区二区三区| 亚洲福利电影网| 免费久久精品视频| 青椒成人免费视频| 成人国产一区二区三区精品| 91丝袜美女网| 欧美一级精品在线| 中文一区在线播放| 午夜一区二区三区在线观看| 国产又黄又大久久| 国产iv一区二区三区| 欧美日韩一区二区三区在线| 精品久久一二三区| 亚洲成人资源在线| 国内精品久久久久影院色| 91在线小视频| 久久久www免费人成精品| 亚洲另类春色国产| 国产乱对白刺激视频不卡| 99精品一区二区三区| 日韩精品最新网址| 婷婷中文字幕一区三区| 99麻豆久久久国产精品免费优播| 精品国产乱码久久久久久浪潮| 亚洲免费观看高清完整版在线观看 | 国产精品亚洲а∨天堂免在线|