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


Java RSAPadding类代码示例

本文整理汇总了Java中sun.security.rsa.RSAPadding的典型用法代码示例。如果您正苦于以下问题:Java RSAPadding类的具体用法?Java RSAPadding怎么用?Java RSAPadding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: checkRSAKeyLength

import sun.security.rsa.RSAPadding; //导入依赖的package包/类
private void checkRSAKeyLength(int len) throws InvalidKeyException {
    RSAPadding padding;
    try {
        padding = RSAPadding.getInstance
            (RSAPadding.PAD_BLOCKTYPE_1, (len + 7) >> 3);
    } catch (InvalidAlgorithmParameterException iape) {
        throw new InvalidKeyException(iape.getMessage());
    }
    int maxDataSize = padding.getMaxDataSize();
    int encodedLength;
    if (algorithm.equals("MD5withRSA") ||
        algorithm.equals("MD2withRSA")) {
        encodedLength = 34;
    } else if (algorithm.equals("SHA1withRSA")) {
        encodedLength = 35;
    } else if (algorithm.equals("SHA224withRSA")) {
        encodedLength = 47;
    } else if (algorithm.equals("SHA256withRSA")) {
        encodedLength = 51;
    } else if (algorithm.equals("SHA384withRSA")) {
        encodedLength = 67;
    } else if (algorithm.equals("SHA512withRSA")) {
        encodedLength = 83;
    } else {
        throw new ProviderException("Unknown signature algo: " + algorithm);
    }
    if (encodedLength > maxDataSize) {
        throw new InvalidKeyException
            ("Key is too short for this signature algorithm");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:P11Signature.java

示例2: pkcs1Pad

import sun.security.rsa.RSAPadding; //导入依赖的package包/类
private byte[] pkcs1Pad(byte[] data) {
    try {
        int len = (p11Key.length() + 7) >> 3;
        RSAPadding padding = RSAPadding.getInstance
                                    (RSAPadding.PAD_BLOCKTYPE_1, len);
        byte[] padded = padding.pad(data);
        return padded;
    } catch (GeneralSecurityException e) {
        throw new ProviderException(e);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:P11Signature.java

示例3: checkRSAKeyLength

import sun.security.rsa.RSAPadding; //导入依赖的package包/类
private void checkRSAKeyLength(int len) throws InvalidKeyException {
    RSAPadding padding;
    try {
        padding = RSAPadding.getInstance
            (RSAPadding.PAD_BLOCKTYPE_1, (len + 7) >> 3);
    } catch (InvalidAlgorithmParameterException iape) {
        throw new InvalidKeyException(iape.getMessage());
    }
    int maxDataSize = padding.getMaxDataSize();
    int encodedLength;
    if (algorithm.equals("MD5withRSA") ||
        algorithm.equals("MD2withRSA")) {
        encodedLength = 34;
    } else if (algorithm.equals("SHA1withRSA")) {
        encodedLength = 35;
    } else if (algorithm.equals("SHA256withRSA")) {
        encodedLength = 51;
    } else if (algorithm.equals("SHA384withRSA")) {
        encodedLength = 67;
    } else if (algorithm.equals("SHA512withRSA")) {
        encodedLength = 83;
    } else {
        throw new ProviderException("Unknown signature algo: " + algorithm);
    }
    if (encodedLength > maxDataSize) {
        throw new InvalidKeyException
            ("Key is too short for this signature algorithm");
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:30,代码来源:P11Signature.java

示例4: pkcs1Pad

import sun.security.rsa.RSAPadding; //导入依赖的package包/类
private byte[] pkcs1Pad(byte[] data) {
    try {
        int len = (p11Key.keyLength() + 7) >> 3;
        RSAPadding padding = RSAPadding.getInstance
                                    (RSAPadding.PAD_BLOCKTYPE_1, len);
        byte[] padded = padding.pad(data);
        return padded;
    } catch (GeneralSecurityException e) {
        throw new ProviderException(e);
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:12,代码来源:P11Signature.java


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