Path: blob/master/src/java.base/share/classes/com/sun/crypto/provider/DESedeParameters.java
41161 views
/*1* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.crypto.provider;2627import java.io.*;28import java.security.AlgorithmParametersSpi;29import java.security.spec.AlgorithmParameterSpec;30import java.security.spec.InvalidParameterSpecException;3132/**33* This class implements the parameter (IV) used with the Triple DES algorithm34* in feedback-mode. IV is defined in the standards as follows:35*36* <pre>37* IV ::= OCTET STRING -- 8 octets38* </pre>39*40* @author Jan Luehe41*42*/43public final class DESedeParameters extends AlgorithmParametersSpi {4445private BlockCipherParamsCore core;4647public DESedeParameters() {48core = new BlockCipherParamsCore(DESConstants.DES_BLOCK_SIZE);49}5051protected void engineInit(AlgorithmParameterSpec paramSpec)52throws InvalidParameterSpecException {53core.init(paramSpec);54}5556protected void engineInit(byte[] encoded)57throws IOException {58core.init(encoded);59}6061protected void engineInit(byte[] encoded, String decodingMethod)62throws IOException {63core.init(encoded, decodingMethod);64}6566protected <T extends AlgorithmParameterSpec>67T engineGetParameterSpec(Class<T> paramSpec)68throws InvalidParameterSpecException {69if (AlgorithmParameterSpec.class.isAssignableFrom(paramSpec)) {70return core.getParameterSpec(paramSpec);71} else {72throw new InvalidParameterSpecException73("Inappropriate parameter Specification");74}75}7677protected byte[] engineGetEncoded() throws IOException {78return core.getEncoded();79}8081protected byte[] engineGetEncoded(String encodingMethod)82throws IOException {83return core.getEncoded();84}8586protected String engineToString() {87return core.toString();88}89}909192