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


Java TlsRsaPremasterSecretParameterSpec类代码示例

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


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

示例1: RSAClientKeyExchange

import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; //导入依赖的package包/类
RSAClientKeyExchange(ProtocolVersion protocolVersion,
        ProtocolVersion maxVersion,
        SecureRandom generator, PublicKey publicKey) throws IOException {
    if (publicKey.getAlgorithm().equals("RSA") == false) {
        throw new SSLKeyException("Public key not of type RSA");
    }
    this.protocolVersion = protocolVersion;

    try {
        String s = ((protocolVersion.v >= ProtocolVersion.TLS12.v) ?
            "SunTls12RsaPremasterSecret" : "SunTlsRsaPremasterSecret");
        KeyGenerator kg = JsseJce.getKeyGenerator(s);
        kg.init(new TlsRsaPremasterSecretParameterSpec(
                maxVersion.v, protocolVersion.v), generator);
        preMaster = kg.generateKey();

        Cipher cipher = JsseJce.getCipher(JsseJce.CIPHER_RSA_PKCS1);
        cipher.init(Cipher.WRAP_MODE, publicKey, generator);
        encrypted = cipher.wrap(preMaster);
    } catch (GeneralSecurityException e) {
        throw (SSLKeyException)new SSLKeyException
                            ("RSA premaster secret error").initCause(e);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:RSAClientKeyExchange.java

示例2: RSAClientKeyExchange

import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; //导入依赖的package包/类
RSAClientKeyExchange(ProtocolVersion protocolVersion,
        ProtocolVersion maxVersion,
        SecureRandom generator, PublicKey publicKey) throws IOException {
    if (publicKey.getAlgorithm().equals("RSA") == false) {
        throw new SSLKeyException("Public key not of type RSA: " +
            publicKey.getAlgorithm());
    }
    this.protocolVersion = protocolVersion;

    try {
        String s = ((protocolVersion.v >= ProtocolVersion.TLS12.v) ?
            "SunTls12RsaPremasterSecret" : "SunTlsRsaPremasterSecret");
        KeyGenerator kg = JsseJce.getKeyGenerator(s);
        kg.init(new TlsRsaPremasterSecretParameterSpec(
                maxVersion.v, protocolVersion.v), generator);
        preMaster = kg.generateKey();

        Cipher cipher = JsseJce.getCipher(JsseJce.CIPHER_RSA_PKCS1);
        cipher.init(Cipher.WRAP_MODE, publicKey, generator);
        encrypted = cipher.wrap(preMaster);
    } catch (GeneralSecurityException e) {
        throw (SSLKeyException)new SSLKeyException
                            ("RSA premaster secret error").initCause(e);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:RSAClientKeyExchange.java

示例3: engineInit

import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; //导入依赖的package包/类
@SuppressWarnings("deprecation")
protected void engineInit(AlgorithmParameterSpec params,
        SecureRandom random) throws InvalidAlgorithmParameterException {
    if (!(params instanceof TlsRsaPremasterSecretParameterSpec)) {
        throw new InvalidAlgorithmParameterException(MSG);
    }

    TlsRsaPremasterSecretParameterSpec spec =
        (TlsRsaPremasterSecretParameterSpec) params;

    int version = (spec.getMajorVersion() << 8) | spec.getMinorVersion();

    if ((version == 0x0300 && !supportSSLv3) || (version < 0x0300) ||
        (version > 0x0302)) {
         throw new InvalidAlgorithmParameterException
                ("Only" + (supportSSLv3? " SSL 3.0,": "") +
                 " TLS 1.0, and TLS 1.1 are supported (0x" +
                 Integer.toHexString(version) + ")");
    }
    this.spec = spec;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:P11TlsRsaPremasterSecretGenerator.java

示例4: RSAClientKeyExchange

import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; //导入依赖的package包/类
@SuppressWarnings("deprecation")
RSAClientKeyExchange(ProtocolVersion protocolVersion,
        ProtocolVersion maxVersion,
        SecureRandom generator, PublicKey publicKey) throws IOException {
    if (publicKey.getAlgorithm().equals("RSA") == false) {
        throw new SSLKeyException("Public key not of type RSA: " +
            publicKey.getAlgorithm());
    }
    this.protocolVersion = protocolVersion;

    try {
        String s = protocolVersion.useTLS12PlusSpec() ?
            "SunTls12RsaPremasterSecret" : "SunTlsRsaPremasterSecret";
        KeyGenerator kg = JsseJce.getKeyGenerator(s);
        kg.init(new TlsRsaPremasterSecretParameterSpec(
                maxVersion.v, protocolVersion.v), generator);
        preMaster = kg.generateKey();

        Cipher cipher = JsseJce.getCipher(JsseJce.CIPHER_RSA_PKCS1);
        cipher.init(Cipher.WRAP_MODE, publicKey, generator);
        encrypted = cipher.wrap(preMaster);
    } catch (GeneralSecurityException e) {
        throw (SSLKeyException)new SSLKeyException
                            ("RSA premaster secret error").initCause(e);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:RSAClientKeyExchange.java

示例5: generatePreMasterSecret

import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; //导入依赖的package包/类
private static SecretKey generatePreMasterSecret(
        ProtocolVersion version, byte[] encodedSecret,
        SecureRandom generator) {

    if (debug != null && Debug.isOn("handshake")) {
        System.out.println("Generating a random fake premaster secret");
    }

    try {
        String s = ((version.v >= ProtocolVersion.TLS12.v) ?
            "SunTls12RsaPremasterSecret" : "SunTlsRsaPremasterSecret");
        KeyGenerator kg = JsseJce.getKeyGenerator(s);
        kg.init(new TlsRsaPremasterSecretParameterSpec(
                version.major, version.minor, encodedSecret), generator);
        return kg.generateKey();
    } catch (InvalidAlgorithmParameterException |
            NoSuchAlgorithmException iae) {
        // unlikely to happen, otherwise, must be a provider exception
        if (debug != null && Debug.isOn("handshake")) {
            System.out.println("RSA premaster secret generation error:");
            iae.printStackTrace(System.out);
        }
        throw new RuntimeException("Could not generate dummy secret", iae);
    }
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:26,代码来源:RSAClientKeyExchange.java

示例6: generateDummySecret

import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; //导入依赖的package包/类
static SecretKey generateDummySecret(ProtocolVersion version) {
    if (debug != null && Debug.isOn("handshake")) {
        System.out.println("Generating a random fake premaster secret");
    }

    try {
        String s = ((version.v >= ProtocolVersion.TLS12.v) ?
            "SunTls12RsaPremasterSecret" : "SunTlsRsaPremasterSecret");
        KeyGenerator kg = JsseJce.getKeyGenerator(s);
        kg.init(new TlsRsaPremasterSecretParameterSpec
                (version.major, version.minor));
        return kg.generateKey();
    } catch (GeneralSecurityException e) {
        throw new RuntimeException("Could not generate dummy secret", e);
    }
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:17,代码来源:RSAClientKeyExchange.java

示例7: engineInit

import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; //导入依赖的package包/类
protected void engineInit(AlgorithmParameterSpec params,
        SecureRandom random) throws InvalidAlgorithmParameterException {
    if (!(params instanceof TlsRsaPremasterSecretParameterSpec)) {
        throw new InvalidAlgorithmParameterException(MSG);
    }
    this.spec = (TlsRsaPremasterSecretParameterSpec)params;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:P11TlsRsaPremasterSecretGenerator.java

示例8: engineInit

import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; //导入依赖的package包/类
protected void engineInit(int opmode, Key key,
        AlgorithmParameterSpec params, SecureRandom random)
        throws InvalidKeyException, InvalidAlgorithmParameterException {
    if (params != null) {
        if (!(params instanceof TlsRsaPremasterSecretParameterSpec)) {
            throw new InvalidAlgorithmParameterException(
                    "Parameters not supported");
        }
        spec = params;
        this.random = random;   // for TLS RSA premaster secret
    }
    implInit(opmode, key);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:P11RSACipher.java

示例9: engineInit

import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; //导入依赖的package包/类
protected void engineInit(AlgorithmParameterSpec params,
        SecureRandom random) throws InvalidAlgorithmParameterException {
    if (!(params instanceof TlsRsaPremasterSecretParameterSpec)) {
        throw new InvalidAlgorithmParameterException(MSG);
    }
    this.spec = (TlsRsaPremasterSecretParameterSpec)params;
    this.random = random;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:TlsRsaPremasterSecretGenerator.java

示例10: engineInit

import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; //导入依赖的package包/类
protected void engineInit(int opmode, Key key,
        AlgorithmParameterSpec params, SecureRandom random)
        throws InvalidKeyException, InvalidAlgorithmParameterException {

    if (params != null) {
        if (!(params instanceof TlsRsaPremasterSecretParameterSpec)) {
            throw new InvalidAlgorithmParameterException(
                    "Parameters not supported");
        }
        spec = params;
        this.random = random;   // for TLS RSA premaster secret
    }
    init(opmode, key);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:RSACipher.java

示例11: generatePreMasterSecret

import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private static SecretKey generatePreMasterSecret(
        int clientVersion, int serverVersion,
        byte[] encodedSecret, SecureRandom generator) {

    if (debug != null && Debug.isOn("handshake")) {
        System.out.println("Generating a premaster secret");
    }

    try {
        String s = ((clientVersion >= ProtocolVersion.TLS12.v) ?
            "SunTls12RsaPremasterSecret" : "SunTlsRsaPremasterSecret");
        KeyGenerator kg = JsseJce.getKeyGenerator(s);
        kg.init(new TlsRsaPremasterSecretParameterSpec(
                clientVersion, serverVersion, encodedSecret),
                generator);
        return kg.generateKey();
    } catch (InvalidAlgorithmParameterException |
            NoSuchAlgorithmException iae) {
        // unlikely to happen, otherwise, must be a provider exception
        if (debug != null && Debug.isOn("handshake")) {
            System.out.println("RSA premaster secret generation error:");
            iae.printStackTrace(System.out);
        }
        throw new RuntimeException("Could not generate premaster secret", iae);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:28,代码来源:RSAClientKeyExchange.java

示例12: test

import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; //导入依赖的package包/类
private static void test(KeyGenerator kg,
        int clientVersion, int serverVersion) throws Exception {

    System.out.printf(
            "Testing RSA pre-master secret key generation between " +
            "client (0x%04X) and server(0x%04X)%n",
            clientVersion, serverVersion);
    kg.init(new TlsRsaPremasterSecretParameterSpec(
                                clientVersion, serverVersion));
    SecretKey key = kg.generateKey();
    byte[] encoded = key.getEncoded();
    if (encoded != null) {  // raw key material may be not extractable
        if (encoded.length != 48) {
            throw new Exception("length: " + encoded.length);
        }
        int v = versionOf(encoded[0], encoded[1]);
        if (clientVersion != v) {
            if (serverVersion != v || clientVersion >= 0x0302) {
                throw new Exception(String.format(
                    "version mismatch: (0x%04X) rather than (0x%04X) " +
                    "is used in pre-master secret", v, clientVersion));
            }
            System.out.printf("Use compatible version (0x%04X)%n", v);
        }
        System.out.println("Passed, version matches!");
   } else {
        System.out.println("Raw key material is not extractable");
   }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:30,代码来源:TestPremaster.java

示例13: test

import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; //导入依赖的package包/类
private static void test(KeyGenerator kg,
        int clientVersion, int serverVersion) throws Exception {

    System.out.printf(
            "Testing RSA pre-master secret key generation between " +
            "client (0x%04X) and server(0x%04X)%n",
            clientVersion, serverVersion);
    kg.init(new TlsRsaPremasterSecretParameterSpec(
                                clientVersion, serverVersion));

    SecretKey key = kg.generateKey();
    byte[] encoded = key.getEncoded();
    if (encoded != null) {  // raw key material may be not extractable
        if (encoded.length != 48) {
            throw new Exception("length: " + encoded.length);
        }
        int v = versionOf(encoded[0], encoded[1]);
        if (clientVersion != v) {
            if (serverVersion != v || clientVersion >= 0x0302) {
                throw new Exception(String.format(
                    "version mismatch: (0x%04X) rather than (0x%04X) " +
                    "is used in pre-master secret", v, clientVersion));
            }
            System.out.printf("Use compatible version (0x%04X)%n", v);
        }
        System.out.println("Passed, version matches!");
   } else {
        System.out.println("Raw key material is not extractable");
   }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:31,代码来源:TestPremaster.java

示例14: engineInit

import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; //导入依赖的package包/类
@SuppressWarnings("deprecation")
protected void engineInit(int opmode, Key key,
        AlgorithmParameterSpec params, SecureRandom random)
        throws InvalidKeyException, InvalidAlgorithmParameterException {
    if (params != null) {
        if (!(params instanceof TlsRsaPremasterSecretParameterSpec)) {
            throw new InvalidAlgorithmParameterException(
                    "Parameters not supported");
        }
        spec = params;
        this.random = random;   // for TLS RSA premaster secret
    }
    implInit(opmode, key);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:P11RSACipher.java

示例15: engineInit

import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; //导入依赖的package包/类
@SuppressWarnings("deprecation")
protected void engineInit(AlgorithmParameterSpec params,
        SecureRandom random) throws InvalidAlgorithmParameterException {
    if (!(params instanceof TlsRsaPremasterSecretParameterSpec)) {
        throw new InvalidAlgorithmParameterException(MSG);
    }
    this.spec = (TlsRsaPremasterSecretParameterSpec)params;
    this.random = random;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:TlsRsaPremasterSecretGenerator.java


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