src/java.base/share/classes/com/sun/crypto/provider/KeyGeneratorCore.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 109,128 **** --- 109,132 ---- abstract static class HmacSHA2KG extends KeyGeneratorSpi { private final KeyGeneratorCore core; protected HmacSHA2KG(String algoName, int len) { core = new KeyGeneratorCore(algoName, len); } + @Override protected void engineInit(SecureRandom random) { core.implInit(random); } + @Override protected void engineInit(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException { core.implInit(params, random); } + @Override protected void engineInit(int keySize, SecureRandom random) { core.implInit(keySize, random); } + @Override protected SecretKey engineGenerateKey() { return core.implGenerateKey(); } public static final class SHA224 extends HmacSHA2KG {
*** 151,174 **** --- 155,182 ---- public static final class RC2KeyGenerator extends KeyGeneratorSpi { private final KeyGeneratorCore core; public RC2KeyGenerator() { core = new KeyGeneratorCore("RC2", 128); } + @Override protected void engineInit(SecureRandom random) { core.implInit(random); } + @Override protected void engineInit(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException { core.implInit(params, random); } + @Override protected void engineInit(int keySize, SecureRandom random) { if ((keySize < 40) || (keySize > 1024)) { throw new InvalidParameterException("Key length for RC2" + " must be between 40 and 1024 bits"); } core.implInit(keySize, random); } + @Override protected SecretKey engineGenerateKey() { return core.implGenerateKey(); } }
*** 176,200 **** --- 184,240 ---- public static final class ARCFOURKeyGenerator extends KeyGeneratorSpi { private final KeyGeneratorCore core; public ARCFOURKeyGenerator() { core = new KeyGeneratorCore("ARCFOUR", 128); } + @Override protected void engineInit(SecureRandom random) { core.implInit(random); } + @Override protected void engineInit(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException { core.implInit(params, random); } + @Override protected void engineInit(int keySize, SecureRandom random) { if ((keySize < 40) || (keySize > 1024)) { throw new InvalidParameterException("Key length for ARCFOUR" + " must be between 40 and 1024 bits"); } core.implInit(keySize, random); } + @Override protected SecretKey engineGenerateKey() { return core.implGenerateKey(); } } + // nested static class for the ChaCha20 key generator + public static final class ChaCha20KeyGenerator extends KeyGeneratorSpi { + private final KeyGeneratorCore core; + public ChaCha20KeyGenerator() { + core = new KeyGeneratorCore("ChaCha20", 256); + } + @Override + protected void engineInit(SecureRandom random) { + core.implInit(random); + } + @Override + protected void engineInit(AlgorithmParameterSpec params, + SecureRandom random) throws InvalidAlgorithmParameterException { + core.implInit(params, random); + } + @Override + protected void engineInit(int keySize, SecureRandom random) { + if (keySize != 256) { + throw new InvalidParameterException( + "Key length for ChaCha20 must be 256 bits"); + } + core.implInit(keySize, random); + } + @Override + protected SecretKey engineGenerateKey() { + return core.implGenerateKey(); + } + } }