当前位置: 首页>>代码示例>>Java>>正文


Java Cipher.WRAP_MODE属性代码示例

本文整理汇总了Java中javax.crypto.Cipher.WRAP_MODE属性的典型用法代码示例。如果您正苦于以下问题:Java Cipher.WRAP_MODE属性的具体用法?Java Cipher.WRAP_MODE怎么用?Java Cipher.WRAP_MODE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.crypto.Cipher的用法示例。


在下文中一共展示了Cipher.WRAP_MODE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: engineGetOutputSize

public int engineGetOutputSize(int inputLen)
{
    int len1, len2, len3;

    len1 = engine.getMac().getMacSize();

    if (key != null)
    {
        len2 = 1 + 2 * (((ECKey)key).getParameters().getCurve().getFieldSize() + 7) / 8;
    }
    else
    {
        throw new IllegalStateException("cipher not initialised");
    }

    if (engine.getCipher() == null)
    {
        len3 = inputLen;
    }
    else if (state == Cipher.ENCRYPT_MODE || state == Cipher.WRAP_MODE)
    {
        len3 = engine.getCipher().getOutputSize(inputLen);
    }
    else if (state == Cipher.DECRYPT_MODE || state == Cipher.UNWRAP_MODE)
    {
        len3 = engine.getCipher().getOutputSize(inputLen - len1 - len2);
    }
    else
    {
        throw new IllegalStateException("cipher not initialised");
    }

    if (state == Cipher.ENCRYPT_MODE || state == Cipher.WRAP_MODE)
    {
        return buffer.size() + len1 + len2 + len3;
    }
    else if (state == Cipher.DECRYPT_MODE || state == Cipher.UNWRAP_MODE)
    {
        return buffer.size() - len1 - len2 + len3;
    }
    else
    {
        throw new IllegalStateException("cipher not initialised");
    }

}
 
开发者ID:Appdome,项目名称:ipack,代码行数:46,代码来源:IESCipher.java

示例2: engineGetOutputSize

protected int engineGetOutputSize(
    int     inputLen) 
{
    if (state == Cipher.ENCRYPT_MODE || state == Cipher.WRAP_MODE)
    {
        return buffer.size() + inputLen + 20; /* SHA1 MAC size */
    }
    else if (state == Cipher.DECRYPT_MODE || state == Cipher.UNWRAP_MODE)
    {
        return buffer.size() + inputLen - 20;
    }
    else
    {
        throw new IllegalStateException("cipher not initialised");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:16,代码来源:CipherSpi.java

示例3: engineInit

protected void engineInit(
    int                 opmode,
    Key                 key,
    SecureRandom        random) 
throws InvalidKeyException
{
    if (opmode == Cipher.ENCRYPT_MODE || opmode == Cipher.WRAP_MODE)
    {
        try
        {
            engineInit(opmode, key, (AlgorithmParameterSpec)null, random);
            return;
        }
        catch (InvalidAlgorithmParameterException e)
        {
            // fall through...
        }
    }

    throw new IllegalArgumentException("can't handle null parameter spec in IES");
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:21,代码来源:CipherSpi.java

示例4: engineGetOutputSize

protected int engineGetOutputSize(
    int     inputLen)
{
    if (state == Cipher.ENCRYPT_MODE || state == Cipher.WRAP_MODE)
    {
        return buffer.size() + inputLen + 20; /* SHA1 MAC size */
    }
    else if (state == Cipher.DECRYPT_MODE || state == Cipher.UNWRAP_MODE)
    {
        return buffer.size() + inputLen - 20;
    }
    else
    {
        throw new IllegalStateException("cipher not initialised");
    }
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:16,代码来源:JCEIESCipher.java

示例5: engineInit

protected void engineInit(
    int                 opmode,
    Key                 key,
    SecureRandom        random)
throws InvalidKeyException
{
    if (opmode == Cipher.ENCRYPT_MODE || opmode == Cipher.WRAP_MODE)
    {
        try
        {
            engineInit(opmode, key, (AlgorithmParameterSpec)null, random);
            return;
        }
        catch (InvalidAlgorithmParameterException e)
        {
            // fall through...
        }
    }

    throw new IllegalArgumentException("can't handle null parameter spec in IES");
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:21,代码来源:JCEIESCipher.java

示例6: engineGetOutputSize

public int engineGetOutputSize(int inputLen)
{
    int len1, len2, len3;

    len1 = engine.getMac().getMacSize();

    if (key != null)
    {
        len2 = ((DHKey)key).getParams().getP().bitLength() / 8 + 1;
    }
    else
    {
        throw new IllegalStateException("cipher not initialised");
    }

    if (engine.getCipher() == null)
    {
        len3 = inputLen;
    }
    else if (state == Cipher.ENCRYPT_MODE || state == Cipher.WRAP_MODE)
    {
        len3 = engine.getCipher().getOutputSize(inputLen);
    }
    else if (state == Cipher.DECRYPT_MODE || state == Cipher.UNWRAP_MODE)
    {
        len3 = engine.getCipher().getOutputSize(inputLen - len1 - len2);
    }
    else
    {
        throw new IllegalStateException("cipher not initialised");
    }

    if (state == Cipher.ENCRYPT_MODE || state == Cipher.WRAP_MODE)
    {
        return buffer.size() + len1 + len2 + len3;
    }
    else if (state == Cipher.DECRYPT_MODE || state == Cipher.UNWRAP_MODE)
    {
        return buffer.size() - len1 - len2 + len3;
    }
    else
    {
        throw new IllegalStateException("IESCipher not initialised");
    }

}
 
开发者ID:Appdome,项目名称:ipack,代码行数:46,代码来源:IESCipher.java


注:本文中的javax.crypto.Cipher.WRAP_MODE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。