001 package org.rrexky.security.crypto.jcef;
002
003 import gnu.crypto.jce.GnuCrypto;
004 import iaik.security.provider.IAIK;
005
006 import java.io.IOException;
007 import java.io.Serializable;
008 import java.security.AlgorithmParameterGenerator;
009 import java.security.AlgorithmParameters;
010 import java.security.InvalidAlgorithmParameterException;
011 import java.security.InvalidKeyException;
012 import java.security.Key;
013 import java.security.KeyFactory;
014 import java.security.KeyPair;
015 import java.security.KeyPairGenerator;
016 import java.security.MessageDigest;
017 import java.security.NoSuchAlgorithmException;
018 import java.security.NoSuchProviderException;
019 import java.security.PrivateKey;
020 import java.security.Provider;
021 import java.security.PublicKey;
022 import java.security.SecureRandom;
023 import java.security.Security;
024 import java.security.Signature;
025 import java.security.SignatureException;
026 import java.security.SignedObject;
027 import java.security.spec.AlgorithmParameterSpec;
028 import java.security.spec.InvalidKeySpecException;
029 import java.security.spec.InvalidParameterSpecException;
030 import java.security.spec.KeySpec;
031 import java.util.HashMap;
032 import java.util.Map;
033
034 import javax.crypto.BadPaddingException;
035 import javax.crypto.Cipher;
036 import javax.crypto.IllegalBlockSizeException;
037 import javax.crypto.Mac;
038 import javax.crypto.NoSuchPaddingException;
039 import javax.crypto.SealedObject;
040 import javax.crypto.SecretKey;
041 import javax.crypto.SecretKeyFactory;
042 import javax.crypto.spec.IvParameterSpec;
043 import javax.crypto.spec.SecretKeySpec;
044
045 import org.apache.commons.lang.ArrayUtils;
046 import org.bouncycastle.jce.provider.BouncyCastleProvider;
047 import org.rrexky.security.crypto.jcef.core.Algorithm;
048 import org.rrexky.security.crypto.jcef.core.AsymmetricKeyGenerator;
049 import org.rrexky.security.crypto.jcef.core.AsymmetricKeyTranslator;
050 import org.rrexky.security.crypto.jcef.core.AsymmetricProtection;
051 import org.rrexky.security.crypto.jcef.core.AuthenticationAlgorithm;
052 import org.rrexky.security.crypto.jcef.core.BlockSymmetricProtection;
053 import org.rrexky.security.crypto.jcef.core.DigitalPBESeal;
054 import org.rrexky.security.crypto.jcef.core.DigitalSeal;
055 import org.rrexky.security.crypto.jcef.core.DigitalSignature;
056 import org.rrexky.security.crypto.jcef.core.FingerPrint;
057 import org.rrexky.security.crypto.jcef.core.Generator;
058 import org.rrexky.security.crypto.jcef.core.JCEFObject;
059 import org.rrexky.security.crypto.jcef.core.JCEFProvider;
060 import org.rrexky.security.crypto.jcef.core.KeyGenerator;
061 import org.rrexky.security.crypto.jcef.core.KeyTranslator;
062 import org.rrexky.security.crypto.jcef.core.PBEProtection;
063 import org.rrexky.security.crypto.jcef.core.ParameterGenerator;
064 import org.rrexky.security.crypto.jcef.core.ParameterTranslator;
065 import org.rrexky.security.crypto.jcef.core.Protection;
066 import org.rrexky.security.crypto.jcef.core.SecureRandomGenerator;
067 import org.rrexky.security.crypto.jcef.core.StreamSymmetricProtection;
068 import org.rrexky.security.crypto.jcef.core.SymmetricKeyGenerator;
069 import org.rrexky.security.crypto.jcef.core.SymmetricKeyTranslator;
070 import org.rrexky.security.crypto.jcef.core.SymmetricProtection;
071 import org.rrexky.security.crypto.jcef.core.Translator;
072 import org.rrexky.security.crypto.jcef.providers.bouncycastle.BouncyCastleJCEFProvider;
073 import org.rrexky.security.crypto.jcef.providers.bouncycastle.asymmetrickeygenerator.DSAAsymmetricKeyGenerator_BouncyCastle;
074 import org.rrexky.security.crypto.jcef.providers.bouncycastle.asymmetrickeytranslator.DSAAsymmetricKeyTranslator_BouncyCastle;
075 import org.rrexky.security.crypto.jcef.providers.bouncycastle.asymmetricprotection.RSA_ISO97961_AP_BC;
076 import org.rrexky.security.crypto.jcef.providers.bouncycastle.blocksymmetricprotection.AESBlockSymmetricProtection_BouncyCastle;
077 import org.rrexky.security.crypto.jcef.providers.bouncycastle.digitalpbeseal.PBEHmacRIPEMD160DigitalPBESeal_BouncyCastle;
078 import org.rrexky.security.crypto.jcef.providers.bouncycastle.digitalseal.HmacMD2DigitalSeal_BouncyCastle;
079 import org.rrexky.security.crypto.jcef.providers.bouncycastle.digitalsignature.RIPEMD256withRSADigitalSignature_BouncyCastle;
080 import org.rrexky.security.crypto.jcef.providers.bouncycastle.fingerprint.TigerFingerPrint_BouncyCastle;
081 import org.rrexky.security.crypto.jcef.providers.bouncycastle.parametertranslator.BlowfishParameterTranslator_BouncyCastle;
082 import org.rrexky.security.crypto.jcef.providers.bouncycastle.pbeprotection.PBEwithMD5andAES128PBEProtection_BouncyCastle;
083 import org.rrexky.security.crypto.jcef.providers.bouncycastle.streamsymmetricprotection.RC4StreamSymmetricProtection_BouncyCastle;
084 import org.rrexky.security.crypto.jcef.providers.bouncycastle.symmetrickeygenerator.CAST5SymmetricKeyGenerator_BouncyCastle;
085 import org.rrexky.security.crypto.jcef.providers.bouncycastle.symmetrickeytranslator.CamelliaSymmetricKeyTranslator_BouncyCastle;
086 import org.rrexky.security.crypto.jcef.providers.cryptix.CryptixJCEFProvider;
087 import org.rrexky.security.crypto.jcef.providers.cryptix.asymmetrickeygenerator.ElGamalAsymmetricKeyGenerator_Cryptix;
088 import org.rrexky.security.crypto.jcef.providers.cryptix.asymmetricprotection.ElGamalAsymmetricProtection_Cryptix;
089 import org.rrexky.security.crypto.jcef.providers.cryptix.blocksymmetricprotection.SquareBlockSymmetricProtection_Cryptix;
090 import org.rrexky.security.crypto.jcef.providers.cryptix.digitalseal.HmacRIPEMD160DigitalSeal_Cryptix;
091 import org.rrexky.security.crypto.jcef.providers.cryptix.digitalsignature.SHA1withElGamalDigitalSignature_Cryptix;
092 import org.rrexky.security.crypto.jcef.providers.cryptix.fingerprint.HavalFingerPrint_Cryptix;
093 import org.rrexky.security.crypto.jcef.providers.cryptix.streamsymmetricprotection.RC4StreamSymmetricProtection_Cryptix;
094 import org.rrexky.security.crypto.jcef.providers.cryptix.symmetrickeygenerator.SquareSymmetricKeyGenerator_Cryptix;
095 import org.rrexky.security.crypto.jcef.providers.cryptix.symmetrickeytranslator.RC2SymmetricKeyTranslator_Cryptix;
096 import org.rrexky.security.crypto.jcef.providers.cryptixcrypto.CryptixCryptoJCEFProvider;
097 import org.rrexky.security.crypto.jcef.providers.cryptixcrypto.asymmetrickeygenerator.DSAAsymmetricKeyGenerator_CryptixCrypto;
098 import org.rrexky.security.crypto.jcef.providers.cryptixcrypto.asymmetrickeytranslator.DSAAsymmetricKeyTranslator_CryptixCrypto;
099 import org.rrexky.security.crypto.jcef.providers.cryptixcrypto.asymmetricprotection.ElGamal_PKCS1_AP_CryptixCrypto;
100 import org.rrexky.security.crypto.jcef.providers.cryptixcrypto.blocksymmetricprotection.AESBlockSymmetricProtection_CryptixCrypto;
101 import org.rrexky.security.crypto.jcef.providers.cryptixcrypto.digitalseal.HmacMD5DigitalSeal_CryptixCrypto;
102 import org.rrexky.security.crypto.jcef.providers.cryptixcrypto.digitalsignature.MD2withRSADigitalSignature_CryptixCrypto;
103 import org.rrexky.security.crypto.jcef.providers.cryptixcrypto.fingerprint.SHA384FingerPrint_CryptixCrypto;
104 import org.rrexky.security.crypto.jcef.providers.cryptixcrypto.streamsymmetricprotection.RC4StreamSymmetricProtection_CryptixCrypto;
105 import org.rrexky.security.crypto.jcef.providers.cryptixcrypto.symmetrickeygenerator.CAST5SymmetricKeyGenerator_CryptixCrypto;
106 import org.rrexky.security.crypto.jcef.providers.cryptixcrypto.symmetrickeytranslator.RC6SymmetricKeyTranslator_CryptixCrypto;
107 import org.rrexky.security.crypto.jcef.providers.flexicore.FlexiCoreJCEFProvider;
108 import org.rrexky.security.crypto.jcef.providers.flexicore.asymmetrickeygenerator.RSAAsymmetricKeyGenerator_FlexiCore;
109 import org.rrexky.security.crypto.jcef.providers.flexicore.asymmetrickeytranslator.RSAAsymmetricKeyTranslator_FlexiCore;
110 import org.rrexky.security.crypto.jcef.providers.flexicore.asymmetricprotection.ElGamalAsymmetricProtection_FlexiCore;
111 import org.rrexky.security.crypto.jcef.providers.flexicore.blocksymmetricprotection.MARSBlockSymmetricProtection_FlexiCore;
112 import org.rrexky.security.crypto.jcef.providers.flexicore.digitalseal.HmacSHA512DigitalSeal_FlexiCore;
113 import org.rrexky.security.crypto.jcef.providers.flexicore.digitalsignature.RIPEMD160withRawRSADigitalSignature_FlexiCore;
114 import org.rrexky.security.crypto.jcef.providers.flexicore.fingerprint.RIPEMD128FingerPrint_FlexiCore;
115 import org.rrexky.security.crypto.jcef.providers.flexicore.parametergenerator.RC5ParameterGenerator_FlexiCore;
116 import org.rrexky.security.crypto.jcef.providers.flexicore.parametertranslator.RC2ParameterTranslator_FlexiCore;
117 import org.rrexky.security.crypto.jcef.providers.flexicore.pbeprotection.PBEwithSHA1andTripleDES192PBEProtection_FlexiCore;
118 import org.rrexky.security.crypto.jcef.providers.flexicore.securerandomgenerator.BBSSecureRandomGenerator_FlexiCore;
119 import org.rrexky.security.crypto.jcef.providers.flexicore.symmetrickeygenerator.SaferPlusPlusSymmetricKeyGenerator_FlexiCore;
120 import org.rrexky.security.crypto.jcef.providers.flexicore.symmetrickeytranslator.SerpentSymmetricKeyTranslator_FlexiCore;
121 import org.rrexky.security.crypto.jcef.providers.flexiec.FlexiECJCEFProvider;
122 import org.rrexky.security.crypto.jcef.providers.flexiec.asymmetrickeygenerator.ECAsymmetricKeyGenerator_FlexiEC;
123 import org.rrexky.security.crypto.jcef.providers.flexiec.asymmetrickeytranslator.ECNRAsymmetricKeyTranslator_FlexiEC;
124 import org.rrexky.security.crypto.jcef.providers.flexiec.asymmetricprotection.IESGF2nAsymmetricProtection_FlexiEC;
125 import org.rrexky.security.crypto.jcef.providers.flexiec.digitalsignature.SHA1withECNRGF2nDigitalSignature_FlexiEC;
126 import org.rrexky.security.crypto.jcef.providers.flexiec.parametergenerator.ECGFPParameterGenerator_FlexiEC;
127 import org.rrexky.security.crypto.jcef.providers.flexiec.parametertranslator.ECDSAParameterTranslator_FlexiEC;
128 import org.rrexky.security.crypto.jcef.providers.flexiec.securerandomgenerator.ECSecureRandomGenerator_FlexiEC;
129 import org.rrexky.security.crypto.jcef.providers.flexinf.FlexiNFJCEFProvider;
130 import org.rrexky.security.crypto.jcef.providers.flexinf.asymmetrickeygenerator.IQGQAsymmetricKeyGenerator_FlexiNF;
131 import org.rrexky.security.crypto.jcef.providers.flexinf.asymmetrickeytranslator.IQRDSAAsymmetricKeyTranslator_FlexiNF;
132 import org.rrexky.security.crypto.jcef.providers.flexinf.digitalsignature.SHA1withIQGQDigitalSignature_FlexiNF;
133 import org.rrexky.security.crypto.jcef.providers.flexinf.parametergenerator.IQGQParameterGenerator_FlexiNF;
134 import org.rrexky.security.crypto.jcef.providers.flexinf.parametertranslator.IQRDSAParameterTranslator_FlexiNF;
135 import org.rrexky.security.crypto.jcef.providers.gnucrypto.GNUCryptoJCEFProvider;
136 import org.rrexky.security.crypto.jcef.providers.gnucrypto.asymmetrickeygenerator.RSAAsymmetricKeyGenerator_GNUCrypto;
137 import org.rrexky.security.crypto.jcef.providers.gnucrypto.blocksymmetricprotection.KhazadBlockSymmetricProtection_GNUCrypto;
138 import org.rrexky.security.crypto.jcef.providers.gnucrypto.digitalseal.HmacHavalDigitalSeal_GNUCrypto;
139 import org.rrexky.security.crypto.jcef.providers.gnucrypto.digitalsignature.NONEwithRSAandPSSDigitalSignature_GNUCrypto;
140 import org.rrexky.security.crypto.jcef.providers.gnucrypto.fingerprint.MD2FingerPrint_GNUCrypto;
141 import org.rrexky.security.crypto.jcef.providers.gnucrypto.parametergenerator.KhazadParameterGenerator_GNUCrypto;
142 import org.rrexky.security.crypto.jcef.providers.gnucrypto.parametertranslator.AnubisParameterTranslator_GNUCrypto;
143 import org.rrexky.security.crypto.jcef.providers.gnucrypto.pbeprotection.PBEwithTigerandAnubisPBEProtection_GNUCrypto;
144 import org.rrexky.security.crypto.jcef.providers.gnucrypto.securerandomgenerator.ICMSecureRandomGenerator_GNUCrypto;
145 import org.rrexky.security.crypto.jcef.providers.gnucrypto.streamsymmetricprotection.RC4StreamSymmetricProtection_GNUCrypto;
146 import org.rrexky.security.crypto.jcef.providers.gnucrypto.symmetrickeygenerator.KhazadSymmetricKeyGenerator_GNUCrypto;
147 import org.rrexky.security.crypto.jcef.providers.gnucrypto.symmetrickeytranslator.AnubisSymmetricKeyTranslator_GNUCrypto;
148 import org.rrexky.security.crypto.jcef.providers.iaik.IAIKJCEFProvider;
149 import org.rrexky.security.crypto.jcef.providers.iaik.asymmetrickeygenerator.RSAAsymmetricKeyGenerator_IAIK;
150 import org.rrexky.security.crypto.jcef.providers.iaik.asymmetrickeytranslator.RSAAsymmetricKeyTranslator_IAIK;
151 import org.rrexky.security.crypto.jcef.providers.iaik.asymmetricprotection.RSAwithOAEPwithMD5andMGF1PaddingAsymmetricProtection_IAIK;
152 import org.rrexky.security.crypto.jcef.providers.iaik.blocksymmetricprotection.SerpentBlockSymmetricProtection_IAIK;
153 import org.rrexky.security.crypto.jcef.providers.iaik.digitalseal.HmacSHA224DigitalSeal_IAIK;
154 import org.rrexky.security.crypto.jcef.providers.iaik.digitalsignature.SHA512withRSADigitalSignature_IAIK;
155 import org.rrexky.security.crypto.jcef.providers.iaik.fingerprint.MD5FingerPrint_IAIK;
156 import org.rrexky.security.crypto.jcef.providers.iaik.parametergenerator.AESParameterGenerator_IAIK;
157 import org.rrexky.security.crypto.jcef.providers.iaik.parametertranslator.RC4ParameterTranslator_IAIK;
158 import org.rrexky.security.crypto.jcef.providers.iaik.pbeprotection.PBEwithSHA1andTripleDES192PBEProtection_IAIK;
159 import org.rrexky.security.crypto.jcef.providers.iaik.streamsymmetricprotection.RC4StreamSymmetricProtection_IAIK;
160 import org.rrexky.security.crypto.jcef.providers.iaik.symmetrickeygenerator.HmacRIPEMD128SymmetricKeyGenerator_IAIK;
161 import org.rrexky.security.crypto.jcef.providers.iaik.symmetrickeytranslator.RC4SymmetricKeyTranslator_IAIK;
162 import org.rrexky.security.crypto.jcef.providers.jacksum.JacksumJCEFProvider;
163 import org.rrexky.security.crypto.jcef.providers.jacksum.fingerprint.Haval192_R4FingerPrint_Jacksum;
164 import org.rrexky.security.crypto.jcef.providers.jhbci.JHBCIJCEFProvider;
165 import org.rrexky.security.crypto.jcef.providers.jhbci.asymmetrickeygenerator.RSAAsymmetricKeyGenerator_JHBCI;
166 import org.rrexky.security.crypto.jcef.providers.jhbci.asymmetrickeytranslator.RSAAsymmetricKeyTranslator_JHBCI;
167 import org.rrexky.security.crypto.jcef.providers.jhbci.asymmetricprotection.RSAAsymmetricProtection_JHBCI;
168 import org.rrexky.security.crypto.jcef.providers.jhbci.blocksymmetricprotection.DESBlockSymmetricProtection_JHBCI;
169 import org.rrexky.security.crypto.jcef.providers.jhbci.digitalsignature.RIPEMD160withRSAandISO97961DigitalSignature_JHBCI;
170 import org.rrexky.security.crypto.jcef.providers.jhbci.fingerprint.RIPEMD160FingerPrint_JHBCI;
171 import org.rrexky.security.crypto.jcef.providers.jhbci.symmetrickeygenerator.TripleDES128SymmetricKeyGenerator_JHBCI;
172 import org.rrexky.security.crypto.jcef.providers.jhbci.symmetrickeytranslator.TripleDES192SymmetricKeyTranslator_JHBCI;
173 import org.rrexky.security.crypto.jcef.providers.logicrypto.LogiCryptoJCEFProvider;
174 import org.rrexky.security.crypto.jcef.providers.logicrypto.asymmetrickeygenerator.RSAAsymmetricKeyGenerator_LogiCrypto;
175 import org.rrexky.security.crypto.jcef.providers.logicrypto.asymmetrickeytranslator.RSAAsymmetricKeyTranslator_LogiCrypto;
176 import org.rrexky.security.crypto.jcef.providers.logicrypto.asymmetricprotection.RSAAsymmetricProtection_LogiCrypto;
177 import org.rrexky.security.crypto.jcef.providers.logicrypto.blocksymmetricprotection.CaesarBlockSymmetricProtection_LogiCrypto;
178 import org.rrexky.security.crypto.jcef.providers.logicrypto.fingerprint.SHA1FingerPrint_LogiCrypto;
179 import org.rrexky.security.crypto.jcef.providers.logicrypto.symmetrickeygenerator.BlowfishSymmetricKeyGenerator_LogiCrypto;
180 import org.rrexky.security.crypto.jcef.providers.logicrypto.symmetrickeytranslator.BlowfishSymmetricKeyTranslator_LogiCrypto;
181 import org.rrexky.security.crypto.jcef.providers.mindbright.MindbrightJCEFProvider;
182 import org.rrexky.security.crypto.jcef.providers.mindbright.asymmetrickeygenerator.DSAAsymmetricKeyGenerator_Mindbright;
183 import org.rrexky.security.crypto.jcef.providers.mindbright.asymmetrickeytranslator.DSAAsymmetricKeyTranslator_Mindbright;
184 import org.rrexky.security.crypto.jcef.providers.mindbright.blocksymmetricprotection.TwofishBlockSymmetricProtection_Mindbright;
185 import org.rrexky.security.crypto.jcef.providers.mindbright.digitalseal.HmacSHA1DigitalSeal_Mindbright;
186 import org.rrexky.security.crypto.jcef.providers.mindbright.digitalsignature.SHA1withDSADigitalSignature_Mindbright;
187 import org.rrexky.security.crypto.jcef.providers.mindbright.fingerprint.MD2FingerPrint_Mindbright;
188 import org.rrexky.security.crypto.jcef.providers.mindbright.securerandomgenerator.BlumBlumShubSecureRandomGenerator_Mindbright;
189 import org.rrexky.security.crypto.jcef.providers.mindbright.streamsymmetricprotection.RC4StreamSymmetricProtection_Mindbright;
190 import org.rrexky.security.crypto.jcef.providers.mindbright.symmetrickeygenerator.DESSymmetricKeyGenerator_Mindbright;
191 import org.rrexky.security.crypto.jcef.providers.mindbright.symmetrickeytranslator.DESSymmetricKeyTranslator_Mindbright;
192 import org.rrexky.security.crypto.jcef.providers.rrexky.blocksymmetricprotection.AES_BlockSymmetricProtectionRREXKY;
193 import org.rrexky.security.crypto.jcef.providers.sun.SUNJCEFProvider;
194 import org.rrexky.security.crypto.jcef.providers.sun.asymmetrickeygenerator.DSAAsymmetricKeyGenerator_SUN;
195 import org.rrexky.security.crypto.jcef.providers.sun.asymmetrickeytranslator.DSAAsymmetricKeyTranslator_SUN;
196 import org.rrexky.security.crypto.jcef.providers.sun.digitalsignature.NONEwithDSADigitalSignature_SUN;
197 import org.rrexky.security.crypto.jcef.providers.sun.fingerprint.SHA256FingerPrint_SUN;
198 import org.rrexky.security.crypto.jcef.providers.sun.parametergenerator.DSAParameterGenerator_SUN;
199 import org.rrexky.security.crypto.jcef.providers.sun.parametertranslator.DSAParameterTranslator_SUN;
200 import org.rrexky.security.crypto.jcef.providers.sunjce.SunJCEJCEFProvider;
201 import org.rrexky.security.crypto.jcef.providers.sunjce.asymmetricprotection.RSAwithOAEPwithSHA256andMGF1PaddingAsymmetricProtection_SunJCE;
202 import org.rrexky.security.crypto.jcef.providers.sunjce.blocksymmetricprotection.AES192BlockSymmetricProtection_SunJCE;
203 import org.rrexky.security.crypto.jcef.providers.sunjce.digitalpbeseal.PBEHmacSHA1DigitalPBESeal_SunJCE;
204 import org.rrexky.security.crypto.jcef.providers.sunjce.digitalseal.HmacSHA256DigitalSeal_SunJCE;
205 import org.rrexky.security.crypto.jcef.providers.sunjce.parametergenerator.RSAOAEPParameterGenerator_SunJCE;
206 import org.rrexky.security.crypto.jcef.providers.sunjce.parametertranslator.RSAOAEPParameterTranslator_SunJCE;
207 import org.rrexky.security.crypto.jcef.providers.sunjce.pbeprotection.PBEwithMD5andTripleDESPBEProtection_SunJCE;
208 import org.rrexky.security.crypto.jcef.providers.sunjce.streamsymmetricprotection.RC4StreamSymmetricProtection_SunJCE;
209 import org.rrexky.security.crypto.jcef.providers.sunjce.symmetrickeygenerator.RC4SymmetricKeyGenerator_SunJCE;
210 import org.rrexky.security.crypto.jcef.providers.sunjce.symmetrickeytranslator.PBEHmacSHA1SymmetricKeyTranslator_SunJCE;
211 import org.rrexky.security.crypto.jcef.providers.sunjsse.SunJSSEJCEFProvider;
212 import org.rrexky.security.crypto.jcef.providers.sunjsse.digitalsignature.MD5andSHA1withRSADigitalSignature_SunJSSE;
213 import org.rrexky.security.crypto.jcef.providers.sunrsasign.SunRsaSignJCEFProvider;
214 import org.rrexky.security.crypto.jcef.providers.sunrsasign.asymmetrickeygenerator.RSAAsymmetricKeyGenerator_SunRsaSign;
215 import org.rrexky.security.crypto.jcef.providers.sunrsasign.asymmetrickeytranslator.RSAAsymmetricKeyTranslator_SunRsaSign;
216 import org.rrexky.security.crypto.jcef.providers.sunrsasign.digitalsignature.SHA1withRSADigitalSignature_SunRsaSign;
217
218 import sun.security.provider.Sun;
219 import sun.security.rsa.SunRsaSign;
220
221 import com.sun.crypto.provider.SunJCE;
222
223 import cryptix.jce.provider.CryptixCrypto;
224 import cryptix.provider.Cryptix;
225 import de.cscc.crypto.provider.JHBCI;
226 import de.flexiprovider.core.FlexiCoreProvider;
227 import de.flexiprovider.ec.FlexiECProvider;
228 import de.flexiprovider.nf.FlexiNFProvider;
229
230 /**
231 * <UL>
232 * Java Cryptographic Extension Framework (JCEF) proporciona las siguientes
233 * funciones:
234 * <LI>Algunos ejemplos comparativos entre JCEF y JCE pueden verse en {@link Examples}</LI>
235 * <LI>Utilizar algoritmos ya existentes (véase {@link UsingAlgorithms})</LI>
236 * <LI>Definir nuevas implementaciones de algoritmos (véase
237 * {@link DefiningAlgorithms})</LI>
238 * <LI>Probar el correcto funcionamiento de los algoritmos (veáse
239 * {@link TestAlgorithms})</LI>
240 * <LI>Manipular objetos seguros (véase {@link UsingSecureObject})</LI>
241 * <LI>Manipular flujos seguros (véase {@link UsingSecureStream})</LI>
242 * <LI>NOTA: Muchas de estas funciones también son proporcionadas por Java
243 * Cryptographic Extension (JCE) pero de una manera mucho más compleja</LI>
244 * </UL>
245 */
246 public class UserGuide extends Object {
247
248 /**
249 * Muestra una serie de ejemplos muy representativos de los valores añadidos que proporciona JCEF y lo dificultoso que puede ser realizar lo mismo con JCE
250 */
251 public static class Examples {
252
253 /**
254 * Mediante JCEF, crea un objeto seguro y obtiene su versión insegura nuevamente. Posteriormente crea y deshace otro objeto seguro reutilizando parámetros generados con anterioridad
255 */
256 public static void example1_JCEF () {
257 try {
258 // 1. Se desea asegurar un objeto
259
260 // 1.1. Definimos un objeto que se desea asegurar
261 String object = "my object";
262
263 // 1.2. Se selecciona un algoritmo de seguridad
264 SymmetricProtection secureAlgorithm = new AES_BlockSymmetricProtectionRREXKY();
265
266 // 1.3. Se inicializa el algoritmo con parámetros concretos si fuera necesario (esta inicialización es opcional)
267 // Esta inicialización es inexistente ya que se desea utilizar unos parámetros nuevos (clave y parámetro generado automáticamente por el algoritmo)
268
269 // 1.4. Se asegura el objeto y se guarda en algún lugar
270 SecureObject secureObject = new SecureObject(object, secureAlgorithm);
271 saveObject(secureObject);
272
273 // 2. Se guardan los parámetros para su posterior uso, ya sea para generar nuevos objetos seguros u obtener objetos asegurados (objetos inseguros) que es lo más habitual
274 byte[] encodedKey = secureAlgorithm.getSymmetricKey().getEncoded();
275 byte[] encodedParameter = secureAlgorithm.getEncodedParameter();
276 saveKey(encodedKey);
277 saveParameter(encodedParameter);
278
279 // ... tiempo más tarde en algún otro lugar del código ...
280
281 // 3. Se desea recuperar el objeto de forma segura
282
283 // 3.1. Cargamos los datos que se necesitan
284 encodedKey = loadKey();
285 encodedParameter = loadParameter();
286
287 // 3.2. Inicializamos el algoritmo con los parámetros apropiados para poder obtener el objeto asegurado
288 secureAlgorithm = new AES_BlockSymmetricProtectionRREXKY();
289 secureAlgorithm.setSymmetricKey(encodedKey);
290 secureAlgorithm.setParameter(encodedParameter);
291
292 // 3.3. Se obtiene el objeto asegurado a partir de su versión en forma de objeto seguro
293 secureObject = (SecureObject)loadObject();
294 object = (String)secureObject.getObject(secureAlgorithm);
295
296 // ... tiempo más tarde en algún otro lugar del código ...
297
298 // 4. Se desea asegurar un nuevo objeto con la misma clave y parámetro en un instante de tiempo posterior
299
300 // 4.1. Se define el nuevo objeto
301 String otherObject = "other object";
302
303 // 4.2. Se cargan los parámetros que se necesitan
304 encodedKey = loadKey();
305 encodedParameter = loadParameter();
306
307 // 4.3. Se inicializa el algoritmo
308 secureAlgorithm = new AES_BlockSymmetricProtectionRREXKY();
309 secureAlgorithm.setSymmetricKey(encodedKey);
310 secureAlgorithm.setParameter(encodedParameter);
311
312 // 4.4. Se asegura el nuevo objeto
313 SecureObject otherSecureObject = new SecureObject(otherObject, secureAlgorithm);
314 saveObject(otherSecureObject);
315
316 // ... tiempo más tarde en algún otro lugar del código ...
317
318 // 5. Se desea recuperar el nuevo objeto asegurado
319
320 // 5.1. Cargamos los datos que se necesitan
321 encodedKey = loadKey();
322 encodedParameter = loadParameter();
323
324 // 5.2. Inicializamos el algoritmo con los parámetros apropiados para poder obtener el objeto asegurado
325 secureAlgorithm = new AES_BlockSymmetricProtectionRREXKY();
326 secureAlgorithm.setSymmetricKey(encodedKey);
327 secureAlgorithm.setParameter(encodedParameter);
328
329 // 5.3. Se obtiene el objeto asegurado a partir de su versión en forma de objeto seguro
330 otherSecureObject = (SecureObject)loadObject();
331 object = (String)otherSecureObject.getObject(secureAlgorithm);
332 }
333 catch (Throwable throwable) {
334 throwable.printStackTrace();
335 return;
336 }
337 }
338
339 private static byte[] encodedKey;
340
341 public static void saveKey (byte[] encodedKey) {
342 Examples.encodedKey = encodedKey;
343 }
344
345 public static byte[] loadKey () {
346 return Examples.encodedKey;
347 }
348
349 private static byte[] encodedParameter;
350
351 public static void saveParameter (byte[] encodedParameter) {
352 Examples.encodedParameter = encodedParameter;
353 }
354
355 public static byte[] loadParameter () {
356 return Examples.encodedParameter;
357 }
358
359 private static Object object;
360
361 public static void saveObject (Object object) {
362 Examples.object = object;
363 }
364
365 public static Object loadObject () {
366 return Examples.object;
367 }
368
369 /**
370 * Mediante JCE, crea un objeto seguro y obtiene su versión insegura nuevamente. Posteriormente crea y deshace otro objeto seguro reutilizando parámetros generados con anterioridad
371 */
372 public static void example1_JCE () {
373 // 1. Se desea asegurar un objeto
374
375 // 1.1. Definimos un objeto que se desea asegurar
376 String object = "my object";
377
378 // 1.2. Se selecciona un algoritmo de seguridad
379
380 // 1.2.1. Es muy posible que sea necesario cargar el proveedor de los algoritmos que se desean utilizar. Esto hay que hacerlo una sola vez
381 Provider provider = new BouncyCastleProvider();
382 Security.addProvider(provider);
383 String providerName = provider.getName();
384
385 // 1.2.2. Se deben generar los parámetros del algoritmo antes de seleccionar el mismo
386
387 // 1.2.2.1. Se genera la fuente de datos aleatorios si fuera necesario (no es el caso)
388 SecureRandom random = null;
389
390 // 1.2.2.2. Se genera la clave
391 Key key = null;
392
393 // 1.2.2.2.1. Se seleccionado el algoritmo generador de claves simétricas para el algoritmo deseado
394 javax.crypto.KeyGenerator keyGenerator = null;
395 try {
396 keyGenerator = javax.crypto.KeyGenerator.getInstance("AES", providerName);
397 } catch (NoSuchAlgorithmException exception) {
398 exception.printStackTrace();
399 return;
400 } catch (NoSuchProviderException exception) {
401 exception.printStackTrace();
402 return;
403 }
404
405 // 1.2.2.2.2. Se inicializa el algoritmo de generación de claves simétricas para el algoritmo deseado
406 int keySize = 256;
407 AlgorithmParameterSpec genParameter = null;
408
409 if (genParameter != null && random == null) {
410 try {
411 keyGenerator.init(genParameter);
412 } catch (InvalidAlgorithmParameterException exception) {
413 exception.printStackTrace();
414 return;
415 }
416 } else if (genParameter != null && random != null) {
417 try {
418 keyGenerator.init(genParameter, random);
419 } catch (InvalidAlgorithmParameterException exception) {
420 exception.printStackTrace();
421 return;
422 }
423 } else if (genParameter == null && keySize > 0 && random == null) {
424 keyGenerator.init(keySize);
425 } else if (genParameter == null && keySize > 0 && random != null) {
426 keyGenerator.init(keySize, random);
427 } else if (genParameter == null && keySize <= 0 && random != null) {
428 keyGenerator.init(random);
429 }
430
431 // 1.2.2.2.3. Se utiliza el generador ya seleccionado e inicializado para generar la clave simétrica
432 key = keyGenerator.generateKey();
433
434 // 1.2.2.3. Se necesita generar además un parámetro para el algoritmo además de la clave generada con anterioridad
435 AlgorithmParameterSpec parameter = null;
436
437 // 1.2.2.3.1. Se indica el tipo de parámetro del que se trata
438 Class parameterType = IvParameterSpec.class;
439
440 // 1.2.2.3.2. Se selecciona el algoritmo generador de parámetros para el algoritmo deseado
441 AlgorithmParameterGenerator parameterGenerator = null;
442 try {
443 parameterGenerator = AlgorithmParameterGenerator.getInstance("AES", providerName);
444 } catch (NoSuchAlgorithmException exception) {
445 exception.printStackTrace();
446 return;
447 } catch (NoSuchProviderException exception) {
448 exception.printStackTrace();
449 return;
450 }
451
452 // 1.2.2.3.3. Se inicializa el algoritmo de generación de parámetros
453 genParameter = null;
454 int parameterSize = 16;
455
456 if (genParameter != null && random == null) {
457 try {
458 parameterGenerator.init(genParameter);
459 } catch (InvalidAlgorithmParameterException exception) {
460 exception.printStackTrace();
461 return;
462 }
463 } else if (genParameter != null && random != null) {
464 try {
465 parameterGenerator.init(genParameter, random);
466 } catch (InvalidAlgorithmParameterException exception) {
467 exception.printStackTrace();
468 return;
469 }
470 } else if (genParameter == null && random == null) {
471 parameterGenerator.init(parameterSize);
472 } else if (genParameter == null && random != null) {
473 parameterGenerator.init(parameterSize, random);
474 }
475
476 // 1.2.2.3.4. Se utiliza el generador para obtener el parámetro necesario para el algoritmo
477 AlgorithmParameters algorithmParameters = parameterGenerator.generateParameters();
478 try {
479 parameter = algorithmParameters.getParameterSpec(parameterType);
480 } catch (InvalidParameterSpecException exception) {
481 exception.printStackTrace();
482 return;
483 }
484
485 // 1.2.3. Se selecciona el algoritmo de seguridad
486 Cipher secureAlgorithm = null;
487 try {
488 secureAlgorithm = Cipher.getInstance("AES/CBC/PKCS7Padding", providerName);
489 } catch (NoSuchAlgorithmException exception) {
490 exception.printStackTrace();
491 return;
492 } catch (NoSuchProviderException exception) {
493 exception.printStackTrace();
494 return;
495 } catch (NoSuchPaddingException exception) {
496 exception.printStackTrace();
497 return;
498 }
499
500 // 1.3. Se inicializa el algoritmo con parámetros concretos si fuera necesario (esta inicialización NO es opcional)
501
502 // 1.3.1. Se inicializa el algoritmo
503 int mode = Cipher.ENCRYPT_MODE;
504
505 if (parameter != null && random == null) {
506 try {
507 secureAlgorithm.init(mode, key, parameter);
508 } catch (InvalidKeyException exception) {
509 exception.printStackTrace();
510 return;
511 } catch (InvalidAlgorithmParameterException exception) {
512 exception.printStackTrace();
513 return;
514 }
515 } else if (parameter != null && random != null) {
516 try {
517 secureAlgorithm.init(mode, key, parameter, random);
518 } catch (InvalidKeyException exception) {
519 exception.printStackTrace();
520 return;
521 } catch (InvalidAlgorithmParameterException exception) {
522 exception.printStackTrace();
523 return;
524 }
525 } else if (parameter == null && random == null) {
526 try {
527 secureAlgorithm.init(mode, key);
528 } catch (InvalidKeyException exception) {
529 exception.printStackTrace();
530 return;
531 }
532 } else if (parameter == null && random != null) {
533 try {
534 secureAlgorithm.init(mode, key, random);
535 } catch (InvalidKeyException exception) {
536 exception.printStackTrace();
537 return;
538 }
539 }
540
541 // 1.3.2. Se capturan los parámetros si se han generado automáticamente. Esto es necesario si no se especifican los algoritmos, e incluso es necesario aunque se especifique puesto que el algoritmo puede ignorar el parámetro indicado por el usuario y generar otro de forma automática
542 try {
543 algorithmParameters = secureAlgorithm.getParameters();
544 }
545 catch (Throwable throwable) {}
546 if (parameter == null && algorithmParameters != null) {
547 if (parameterType == null) {
548 parameterType = AlgorithmParameterSpec.class;
549 }
550 try {
551 parameter = algorithmParameters.getParameterSpec(parameterType);
552 } catch (InvalidParameterSpecException exception) {
553 exception.printStackTrace();
554 return;
555 }
556 }
557
558 // 1.4. Se asegura el objeto y se guarda en algún lugar
559 SealedObject secureObject = null;
560 try {
561 secureObject = new SealedObject(object, secureAlgorithm);
562 } catch (IllegalBlockSizeException exception) {
563 exception.printStackTrace();
564 return;
565 } catch (IOException exception) {
566 exception.printStackTrace();
567 return;
568 }
569 saveObject(secureObject);
570
571 // 2. Se guardan los parámetros para su posterior uso, ya sea para generar nuevos objetos seguros u obtener objetos asegurados (objetos inseguros) que es lo más habitual
572
573 // 2.1. Se traducen los parámetros a su versión persistente
574
575 // 2.1.1. Se traduce la clave a su versión persistente. En este caso es sencillo. Pero en otras ocasiones es distinto y en otras es necesario conocer el algoritmo de traducción dificultando el proceso mucho más al no ser homogéneo ya que también se utiliza para traducciones un algoritmo de tipo SecretKeyFactory tal y como se ve en los comentarios siguientes.
576
577 // 2.1.1.1. Esta es la forma básica suministrada. Sin embargo, para los parámetros se proporcionan mecanismos más avanzados al permitir formatos de codificación pero son más complicados
578 encodedKey = key.getEncoded();
579
580 // // 2.1.1.2. Si fuera necesario, también se puede convertir la clave a una forma no transparente para poder inspeccionar sus componentes y esto igualmente complejo de realizar con JCE tal y como se muestra a continuación
581 // SecretKeyFactory symmetricKeyTranslator = null;
582 // try {
583 // symmetricKeyTranslator = SecretKeyFactory.getInstance("AES", providerName);
584 // } catch (NoSuchAlgorithmException exception) {
585 // exception.printStackTrace();
586 // return;
587 // } catch (NoSuchProviderException exception) {
588 // exception.printStackTrace();
589 // return;
590 // }
591 // Class keyType = null;
592 // KeySpec keySpec = null;
593 // try {
594 // keySpec = symmetricKeyTranslator.getKeySpec((SecretKey)key, keyType);
595 // } catch (InvalidKeySpecException exception) {
596 // exception.printStackTrace();
597 // return;
598 // }
599 // // ... y vuelta a los orígenes
600 // try {
601 // key = symmetricKeyTranslator.generateSecret(keySpec);
602 // } catch (InvalidKeySpecException exception) {
603 // exception.printStackTrace();
604 // return;
605 // }
606
607 // 2.1.2. Se traduce el parámetro a su versión persistente. En este caso es sencillo pero no es más que la traducción manual de un caso particular. En general se necesita manejar un algoritmo del tipo AlgorithmParameters dificultando mucho más el proceso tal y como se muestra a continuación. En total se muestra la forma manual pero particular y la forma "automática" general. Observando en esta última que se utiliza un nombre distinto para el algoritmo de traducción que para el algoritmo de protección/desprotección aunque sean nombres "sinónimos"/alias o equivalentes
608
609 // 2.1.2.1. Forma manual pero particular de traducir este parámetro
610 if (parameter instanceof IvParameterSpec) {
611 IvParameterSpec iv = (IvParameterSpec)parameter;
612 encodedParameter = iv.getIV();
613 }
614
615 // 2.1.2.2. Forma "automática" pero general de traducir cualquier parámetro
616 AlgorithmParameters parameterTranslator = null;
617 try {
618 parameterTranslator = AlgorithmParameters.getInstance("RIJNDAEL", providerName);
619 } catch (NoSuchAlgorithmException exception) {
620 exception.printStackTrace();
621 return;
622 } catch (NoSuchProviderException exception) {
623 exception.printStackTrace();
624 return;
625 }
626 try {
627 parameterTranslator.init(parameter);
628 } catch (InvalidParameterSpecException exception) {
629 exception.printStackTrace();
630 return;
631 }
632 try {
633 encodedParameter = parameterTranslator.getEncoded();
634 } catch (IOException exception) {
635 exception.printStackTrace();
636 return;
637 }
638
639 // 2.2. Se guardan los parámetros
640 saveKey(encodedKey);
641 saveParameter(encodedParameter);
642
643 // ... tiempo más tarde en algún otro lugar del código ...
644
645 // 3. Se desea recuperar el objeto de forma segura
646
647 // 3.1. Cargamos los datos que se necesitan
648 encodedKey = loadKey();
649 encodedParameter = loadParameter();
650
651 // 3.2. Inicializamos el algoritmo con los parámetros apropiados para poder obtener el objeto asegurado
652
653 // 3.2.1. Se selecciona el algoritmo para desproteger el objeto seguro
654 try {
655 secureAlgorithm = Cipher.getInstance("AES/CBC/PKCS7Padding", providerName);
656 } catch (NoSuchAlgorithmException exception) {
657 exception.printStackTrace();
658 return;
659 } catch (NoSuchProviderException exception) {
660 exception.printStackTrace();
661 return;
662 } catch (NoSuchPaddingException exception) {
663 exception.printStackTrace();
664 return;
665 }
666
667 // 3.2.2. Se inicializa el algoritmo para desprotección
668
669 // 3.2.2.1. Es necesario convertir los parámetros en su forma adecuada
670
671 // 3.2.2.1.1. Se reconvierte la clave a la forma adecuada
672 key = new SecretKeySpec(encodedKey, "AES");
673
674 // 3.2.2.1.2. Se reconvierte el parámetro a la forma adecuada
675 parameterType = IvParameterSpec.class;
676 parameterTranslator = null;
677 try {
678 parameterTranslator = AlgorithmParameters.getInstance("RIJNDAEL", providerName);
679 } catch (NoSuchAlgorithmException exception) {
680 exception.printStackTrace();
681 return;
682 } catch (NoSuchProviderException exception) {
683 exception.printStackTrace();
684 return;
685 }
686 try {
687 parameterTranslator.init(encodedParameter);
688 } catch (IOException exception) {
689 exception.printStackTrace();
690 return;
691 }
692 try {
693 parameter = parameterTranslator.getParameterSpec(parameterType);
694 } catch (InvalidParameterSpecException exception) {
695 exception.printStackTrace();
696 return;
697 }
698
699 // 3.2.2.2. Se inicializa el algoritmo para desprotección
700 mode = Cipher.DECRYPT_MODE;
701
702 if (parameter != null && random == null) {
703 try {
704 secureAlgorithm.init(mode, key, parameter);
705 } catch (InvalidKeyException exception) {
706 exception.printStackTrace();
707 return;
708 } catch (InvalidAlgorithmParameterException exception) {
709 exception.printStackTrace();
710 return;
711 }
712 } else if (parameter != null && random != null) {
713 try {
714 secureAlgorithm.init(mode, key, parameter, random);
715 } catch (InvalidKeyException exception) {
716 exception.printStackTrace();
717 return;
718 } catch (InvalidAlgorithmParameterException exception) {
719 exception.printStackTrace();
720 return;
721 }
722 } else if (parameter == null && random == null) {
723 try {
724 secureAlgorithm.init(mode, key);
725 } catch (InvalidKeyException exception) {
726 exception.printStackTrace();
727 return;
728 }
729 } else if (parameter == null && random != null) {
730 try {
731 secureAlgorithm.init(mode, key, random);
732 } catch (InvalidKeyException exception) {
733 exception.printStackTrace();
734 return;
735 }
736 }
737
738 // 3.3. Se obtiene el objeto asegurado a partir de su versión en forma de objeto seguro
739 try {
740 secureObject = (SealedObject)loadObject();
741 object = (String)secureObject.getObject(secureAlgorithm);
742 } catch (IllegalBlockSizeException exception) {
743 exception.printStackTrace();
744 return;
745 } catch (BadPaddingException exception) {
746 exception.printStackTrace();
747 return;
748 } catch (IOException exception) {
749 exception.printStackTrace();
750 return;
751 } catch (ClassNotFoundException exception) {
752 exception.printStackTrace();
753 return;
754 }
755
756 // ... tiempo más tarde en algún otro lugar del código ...
757
758 // 4. Se desea asegurar un nuevo objeto con la misma clave y parámetro en un instante de tiempo posterior
759
760 // 4.1. Se define el nuevo objeto
761 String otherObject = "other object";
762
763 // 4.2. Se cargan los parámetros que se necesitan
764 encodedKey = loadKey();
765 encodedParameter = loadParameter();
766
767 // 4.3. Se inicializa el algoritmo
768
769 // 4.3.1. Se reconvierten los parámetros a la forma adecuada
770
771 // 4.3.1.1. Se reconvierte la clave a la forma adecuada
772 key = new SecretKeySpec(encodedKey, "AES");
773
774 // 4.3.1.2. Se reconvierte el parámetro a la forma adecuada
775 parameterType = IvParameterSpec.class;
776 parameterTranslator = null;
777 try {
778 parameterTranslator = AlgorithmParameters.getInstance("RIJNDAEL", providerName);
779 } catch (NoSuchAlgorithmException exception) {
780 exception.printStackTrace();
781 return;
782 } catch (NoSuchProviderException exception) {
783 exception.printStackTrace();
784 return;
785 }
786 try {
787 parameterTranslator.init(encodedParameter);
788 } catch (IOException exception) {
789 exception.printStackTrace();
790 return;
791 }
792 try {
793 parameter = parameterTranslator.getParameterSpec(parameterType);
794 } catch (InvalidParameterSpecException exception) {
795 exception.printStackTrace();
796 return;
797 }
798
799 // 4.3.2. Se selecciona el algoritmo de seguridad
800 secureAlgorithm = null;
801 try {
802 secureAlgorithm = Cipher.getInstance("AES/CBC/PKCS7Padding", providerName);
803 } catch (NoSuchAlgorithmException exception) {
804 exception.printStackTrace();
805 return;
806 } catch (NoSuchProviderException exception) {
807 exception.printStackTrace();
808 return;
809 } catch (NoSuchPaddingException exception) {
810 exception.printStackTrace();
811 return;
812 }
813
814 // 4.3.3. Se inicializa el algoritmo con parámetros concretos (esta inicialización NO es opcional)
815
816 // 4.3.3.1. Se inicializa el algoritmo
817 mode = Cipher.ENCRYPT_MODE;
818
819 if (parameter != null && random == null) {
820 try {
821 secureAlgorithm.init(mode, key, parameter);
822 } catch (InvalidKeyException exception) {
823 exception.printStackTrace();
824 return;
825 } catch (InvalidAlgorithmParameterException exception) {
826 exception.printStackTrace();
827 return;
828 }
829 } else if (parameter != null && random != null) {
830 try {
831 secureAlgorithm.init(mode, key, parameter, random);
832 } catch (InvalidKeyException exception) {
833 exception.printStackTrace();
834 return;
835 } catch (InvalidAlgorithmParameterException exception) {
836 exception.printStackTrace();
837 return;
838 }
839 } else if (parameter == null && random == null) {
840 try {
841 secureAlgorithm.init(mode, key);
842 } catch (InvalidKeyException exception) {
843 exception.printStackTrace();
844 return;
845 }
846 } else if (parameter == null && random != null) {
847 try {
848 secureAlgorithm.init(mode, key, random);
849 } catch (InvalidKeyException exception) {
850 exception.printStackTrace();
851 return;
852 }
853 }
854
855 // 4.3.3.2. Se capturan los parámetros si se han generado automáticamente. Esto es necesario si no se especifican los algoritmos, e incluso es necesario aunque se especifique puesto que el algoritmo puede ignorar el parámetro indicado por el usuario y generar otro de forma automática
856 try {
857 algorithmParameters = secureAlgorithm.getParameters();
858 }
859 catch (Throwable throwable) {}
860 if (parameter == null && algorithmParameters != null) {
861 if (parameterType == null) {
862 parameterType = AlgorithmParameterSpec.class;
863 }
864 try {
865 parameter = algorithmParameters.getParameterSpec(parameterType);
866 } catch (InvalidParameterSpecException exception) {
867 exception.printStackTrace();
868 return;
869 }
870 }
871
872 // 4.4. Se asegura el nuevo objeto y se guarda en algún lugar
873 SealedObject otherSecureObject = null;
874 try {
875 otherSecureObject = new SealedObject(otherObject, secureAlgorithm);
876 } catch (IllegalBlockSizeException exception) {
877 exception.printStackTrace();
878 return;
879 } catch (IOException exception) {
880 exception.printStackTrace();
881 return;
882 }
883 saveObject(otherSecureObject);
884
885 // ... tiempo más tarde en algún otro lugar del código ...
886
887 // 5. Se desea recuperar el nuevo objeto asegurado
888
889 // 5.1. Cargamos los datos que se necesitan
890 encodedKey = loadKey();
891 encodedParameter = loadParameter();
892
893 // 5.2. Inicializamos el algoritmo con los parámetros apropiados para poder obtener el objeto asegurado
894
895 // 5.2.1. Se selecciona el algoritmo para desproteger el objeto seguro
896 try {
897 secureAlgorithm = Cipher.getInstance("AES/CBC/PKCS7Padding", providerName);
898 } catch (NoSuchAlgorithmException exception) {
899 exception.printStackTrace();
900 return;
901 } catch (NoSuchProviderException exception) {
902 exception.printStackTrace();
903 return;
904 } catch (NoSuchPaddingException exception) {
905 exception.printStackTrace();
906 return;
907 }
908
909 // 5.2.2. Se inicializa el algoritmo para desprotección
910
911 // 5.2.2.1. Es necesario convertir los parámetros en su forma adecuada
912
913 // 5.2.2.1.1. Se reconvierte la clave a la forma adecuada
914 key = new SecretKeySpec(encodedKey, "AES");
915
916 // 5.2.2.1.2. Se reconvierte el parámetro a la forma adecuada
917 parameterType = IvParameterSpec.class;
918 parameterTranslator = null;
919 try {
920 parameterTranslator = AlgorithmParameters.getInstance("RIJNDAEL", providerName);
921 } catch (NoSuchAlgorithmException exception) {
922 exception.printStackTrace();
923 return;
924 } catch (NoSuchProviderException exception) {
925 exception.printStackTrace();
926 return;
927 }
928 try {
929 parameterTranslator.init(encodedParameter);
930 } catch (IOException exception) {
931 exception.printStackTrace();
932 return;
933 }
934 try {
935 parameter = parameterTranslator.getParameterSpec(parameterType);
936 } catch (InvalidParameterSpecException exception) {
937 exception.printStackTrace();
938 return;
939 }
940
941 // 5.2.2.2. Se inicializa el algoritmo para desprotección
942 mode = Cipher.DECRYPT_MODE;
943
944 if (parameter != null && random == null) {
945 try {
946 secureAlgorithm.init(mode, key, parameter);
947 } catch (InvalidKeyException exception) {
948 exception.printStackTrace();
949 return;
950 } catch (InvalidAlgorithmParameterException exception) {
951 exception.printStackTrace();
952 return;
953 }
954 } else if (parameter != null && random != null) {
955 try {
956 secureAlgorithm.init(mode, key, parameter, random);
957 } catch (InvalidKeyException exception) {
958 exception.printStackTrace();
959 return;
960 } catch (InvalidAlgorithmParameterException exception) {
961 exception.printStackTrace();
962 return;
963 }
964 } else if (parameter == null && random == null) {
965 try {
966 secureAlgorithm.init(mode, key);
967 } catch (InvalidKeyException exception) {
968 exception.printStackTrace();
969 return;
970 }
971 } else if (parameter == null && random != null) {
972 try {
973 secureAlgorithm.init(mode, key, random);
974 } catch (InvalidKeyException exception) {
975 exception.printStackTrace();
976 return;
977 }
978 }
979
980 // 5.3. Se obtiene el objeto asegurado a partir de su versión en forma de objeto seguro
981 try {
982 otherSecureObject = (SealedObject)loadObject();
983 object = (String)otherSecureObject.getObject(secureAlgorithm);
984 } catch (IllegalBlockSizeException exception) {
985 exception.printStackTrace();
986 return;
987 } catch (BadPaddingException exception) {
988 exception.printStackTrace();
989 return;
990 } catch (IOException exception) {
991 exception.printStackTrace();
992 return;
993 } catch (ClassNotFoundException exception) {
994 exception.printStackTrace();
995 return;
996 }
997 }
998
999 }
1000
1001 /**
1002 * Muestra cómo se obtiene la configuración y se define una nueva tanto en JCEF
1003 * como JCE
1004 */
1005 public static class ConfiguratingAlgorithms {
1006
1007 /**
1008 * Obtiene la configuración de un objeto JCEF
1009 *
1010 * @param object
1011 * Objeto JCEF
1012 * @return Configuración
1013 * @see JCEFObject#getAliases()
1014 * @see JCEFObject#getName()
1015 * @see JCEFObject#getAttributeNames()
1016 * @see JCEFObject#getAttribute(String)
1017 * @see JCEFObject
1018 * @see #getConfiguration_JCEF(Algorithm)
1019 * @see #getConfiguration_JCEF(JCEFProvider)
1020 */
1021 public static Map getConfiguration_JCEF(JCEFObject object) {
1022 Map result = new HashMap();
1023 String[] aliases = object.getAliases();
1024 String name = object.getName();
1025 String[] attributeNames = object.getAttributeNames();
1026 HashMap attributes = new HashMap();
1027
1028 for (int i = 0; (attributeNames != null) && (i < attributeNames.length); i++) {
1029 String attributeName = attributeNames[i];
1030 Object attribute = object.getAttribute(attributeName);
1031 attributes.put(attributeName, attribute);
1032 }
1033
1034 result.put("aliases", aliases);
1035 result.put("name", name);
1036 result.put("attributeNames", attributeNames);
1037 result.put("attributes", attributes);
1038
1039 return result;
1040 }
1041
1042 /**
1043 * Define la configuración de un objeto JCEF
1044 *
1045 * @param object
1046 * Objeto JCEF
1047 * @param configuration
1048 * Configuración
1049 * @see #configure_JCEF(JCEFObject, String[], String, Map)
1050 * @see #setConfiguration_JCEF(Algorithm, Map)
1051 * @see #setConfiguration_JCEF(JCEFProvider, Map)
1052 */
1053 public static void setConfiguration_JCEF(JCEFObject object,
1054 Map configuration) {
1055 String[] aliases = (String[]) configuration.get("aliases");
1056 String name = (String) configuration.get("name");
1057 Map attributes = (Map) configuration.get("attributes");
1058 configure_JCEF(object, aliases, name, attributes);
1059 }
1060
1061 /**
1062 * Configura de forma específica un objeto JCEF
1063 *
1064 * @param object
1065 * Objeto JCEF
1066 * @param aliases
1067 * Parámetro de configuración para
1068 * {@link JCEFObject#setAliases(String[])}
1069 * @param name
1070 * Parámetro de configuración para
1071 * {@link JCEFObject#setName(String)}
1072 * @param attributes
1073 * Parámetro de configuración para
1074 * {@link JCEFObject#setAttribute(String, Object)}
1075 * @see JCEFObject#setAliases(String[])
1076 * @see JCEFObject#setName(String)
1077 * @see JCEFObject#setAttribute(String, Object)
1078 * @see JCEFObject
1079 * @see #setConfiguration_JCEF(JCEFObject, Map)
1080 */
1081 public static void configure_JCEF(JCEFObject object, String[] aliases,
1082 String name, Map attributes) {
1083 object.setAliases(aliases);
1084 object.setName(name);
1085
1086 Object[] attributeNames = attributes.keySet().toArray();
1087
1088 for (int i = 0; (attributeNames != null) && (i < attributeNames.length); i++) {
1089 String attributeName = (String) attributeNames[i];
1090 Object attribute = attributes.get(attributeName);
1091 object.setAttribute(attributeName, attribute);
1092 }
1093 }
1094
1095 /**
1096 * Obtiene la configuración de un proveedor JCEF
1097 *
1098 * @param provider
1099 * Proveedor JCEF
1100 * @return Configuración
1101 * @see JCEFProvider
1102 * @see JCEFProvider#getAlgorithms()
1103 * @see #getConfiguration_JCEF(JCEFObject)
1104 */
1105 public static Map getConfiguration_JCEF(JCEFProvider provider) {
1106 Map result = getConfiguration_JCEF((JCEFObject) provider);
1107 Algorithm[] algorithms = provider.getAlgorithms();
1108 result.put("algorithms", algorithms);
1109
1110 return result;
1111 }
1112
1113 /**
1114 * Define la configuración de un proveedor JCEF
1115 *
1116 * @see JCEFProvider
1117 * @see #setConfiguration_JCEF(JCEFObject, Map)
1118 * @see #configure_JCEF(JCEFProvider, Algorithm[])
1119 */
1120 public static void setConfiguration_JCEF(JCEFProvider provider,
1121 Map configuration) {
1122 setConfiguration_JCEF((JCEFObject) provider, configuration);
1123
1124 Algorithm[] algorithms = (Algorithm[]) configuration.get("algorithms");
1125 configure_JCEF(provider, algorithms);
1126 }
1127
1128 /**
1129 * Configura de forma específica un proveedor JCEF
1130 *
1131 * @param provider
1132 * Proveedor JCEF
1133 * @param algorithms
1134 * Parámetro de configuración para
1135 * {@link JCEFProvider#setAlgorithms(Algorithm[])}
1136 * @see JCEFProvider#setAlgorithms(Algorithm[])
1137 * @see JCEFProvider
1138 * @see #setConfiguration_JCEF(JCEFProvider, Map)
1139 */
1140 public static void configure_JCEF(JCEFProvider provider,
1141 Algorithm[] algorithms) {
1142 provider.setAlgorithms(algorithms);
1143 }
1144
1145 /**
1146 * Obtiene la configuración de un algoritmo JCEF
1147 *
1148 * @param algorithm
1149 * Algoritmo JCEF
1150 * @return Configuración
1151 * @see Algorithm#getDefaultAdditionalParameter()
1152 * @see Algorithm#getAdditionalParameters()
1153 * @see Algorithm#getAdditionalParameterType()
1154 * @see Algorithm
1155 * @see #getConfiguration_JCEF(JCEFObject)
1156 * @see #getConfiguration_JCEF(Generator)
1157 * @see #getConfiguration_JCEF(Translator)
1158 * @see #getConfiguration_JCEF(CryptoAlgorithm)
1159 */
1160 public static Map getConfiguration_JCEF(Algorithm algorithm) {
1161 Map result = getConfiguration_JCEF((JCEFObject) algorithm);
1162 AlgorithmParameterSpec defaultAdditionalParameter = algorithm
1163 .getDefaultAdditionalParameter();
1164 AlgorithmParameterSpec[] additionalParameters = algorithm
1165 .getAdditionalParameters();
1166 Class additionalParameterType = algorithm.getAdditionalParameterType();
1167 result.put("defaultAdditionalParameter", defaultAdditionalParameter);
1168 result.put("additionalParameters", additionalParameters);
1169 result.put("additionalParameterType", additionalParameterType);
1170
1171 return result;
1172 }
1173
1174 /**
1175 * Define la configuración de un algoritmo JCEF
1176 *
1177 * @param algorithm
1178 * Algoritmo JCEF
1179 * @param configuration
1180 * Configuración
1181 * @see Algorithm
1182 * @see #configure_JCEF(Algorithm, AlgorithmParameterSpec,
1183 * AlgorithmParameterSpec[], Class)
1184 * @see #setConfiguration_JCEF(JCEFObject, Map)
1185 * @see #setConfiguration_JCEF(Generator, Map)
1186 * @see #setConfiguration_JCEF(Translator, Map)
1187 * @see #setConfiguration_JCEF(CryptoAlgorithm, Map)
1188 */
1189 public static void setConfiguration_JCEF(Algorithm algorithm,
1190 Map configuration) {
1191 setConfiguration_JCEF((JCEFObject) algorithm, configuration);
1192
1193 AlgorithmParameterSpec defaultAdditionalParameter = (AlgorithmParameterSpec) configuration
1194 .get("defaultAdditionalParameter");
1195 AlgorithmParameterSpec[] additionalParameters = (AlgorithmParameterSpec[]) configuration
1196 .get("additionalParameters");
1197 Class additionalParameterType = (Class) configuration
1198 .get("additionalParameterType");
1199 configure_JCEF(algorithm, defaultAdditionalParameter,
1200 additionalParameters, additionalParameterType);
1201 }
1202
1203 /**
1204 * Configura de forma específica un algoritmo JCEF
1205 *
1206 * @param algorithm
1207 * Algoritmo JCEF
1208 * @param defaultAdditionalParameter
1209 * Parámetro para
1210 * {@link Algorithm#setDefaultAdditionalParameter(AlgorithmParameterSpec)}
1211 * @param additionalParameters
1212 * Parámetro para
1213 * {@link Algorithm#setAdditionalParameters(AlgorithmParameterSpec[])}
1214 * @param additionalParameterType
1215 * Parámetro para
1216 * {@link Algorithm#setAdditionalParameterType(Class)}
1217 * @see Algorithm#setDefaultAdditionalParameter(AlgorithmParameterSpec)
1218 * @see Algorithm#setAdditionalParameters(AlgorithmParameterSpec[])
1219 * @see Algorithm#setAdditionalParameterType(Class)
1220 * @see #setConfiguration_JCEF(Algorithm, Map)
1221 */
1222 public static void configure_JCEF(Algorithm algorithm,
1223 AlgorithmParameterSpec defaultAdditionalParameter,
1224 AlgorithmParameterSpec[] additionalParameters,
1225 Class additionalParameterType) {
1226 algorithm.setDefaultAdditionalParameter(defaultAdditionalParameter);
1227 algorithm.setAdditionalParameters(additionalParameters);
1228 algorithm.setAdditionalParameterType(additionalParameterType);
1229 }
1230
1231 /**
1232 * Obtiene la configuración de un generador JCEF
1233 *
1234 * @param algorithm
1235 * Generador JCEF
1236 * @return Configuración
1237 * @see Generator#getSecureRandomGenerator()
1238 * @see Generator#getDefaultGenParameter()
1239 * @see Generator#getAvailableGenParameters()
1240 * @see Generator#getGenParameterType()
1241 * @see Generator
1242 * @see #getConfiguration_JCEF(Algorithm)
1243 * @see #getConfiguration_JCEF(KeyGenerator)
1244 * @see #getConfiguration_JCEF(ParameterGenerator)
1245 * @see #getConfiguration_JCEF(SecureRandomGenerator)
1246 */
1247 public static Map getConfiguration_JCEF(Generator algorithm) {
1248 Map result = getConfiguration_JCEF((Algorithm) algorithm);
1249 SecureRandomGenerator secureRandomGenerator = algorithm
1250 .getSecureRandomGenerator();
1251 AlgorithmParameterSpec defaultGenParameter = algorithm
1252 .getDefaultGenParameter();
1253 AlgorithmParameterSpec[] availableGenParameters = algorithm
1254 .getAvailableGenParameters();
1255 Class genParameterType = algorithm.getGenParameterType();
1256 result.put("secureRandomGenerator", secureRandomGenerator);
1257 result.put("defaultGenParameter", defaultGenParameter);
1258 result.put("availableGenParameters", availableGenParameters);
1259 result.put("genParameterType", genParameterType);
1260
1261 return result;
1262 }
1263
1264 /**
1265 * Define la configuración de un algoritmo generador JCEF
1266 *
1267 * @param algorithm
1268 * @param configuration
1269 * @see #configure_JCEF(Generator, AlgorithmParameterSpec,
1270 * AlgorithmParameterSpec[], Class, SecureRandomGenerator)
1271 * @see Generator
1272 * @see #setConfiguration_JCEF(Algorithm, Map)
1273 * @see #setConfiguration_JCEF(KeyGenerator, Map)
1274 * @see #setConfiguration_JCEF(ParameterGenerator, Map)
1275 * @see #setConfiguration_JCEF(SecureRandomGenerator, Map)
1276 */
1277 public static void setConfiguration_JCEF(Generator algorithm,
1278 Map configuration) {
1279 setConfiguration_JCEF((Algorithm) algorithm, configuration);
1280
1281 AlgorithmParameterSpec defaultGenParameter = (AlgorithmParameterSpec) configuration
1282 .get("defaultGenParameter");
1283 AlgorithmParameterSpec[] availableGenParameters = (AlgorithmParameterSpec[]) configuration
1284 .get("availableGenParameters");
1285 Class genParameterType = (Class) configuration.get("genParameterType");
1286 SecureRandomGenerator secureRandomGenerator = (SecureRandomGenerator) configuration
1287 .get("secureRandomGenerator");
1288 configure_JCEF(algorithm, defaultGenParameter, availableGenParameters,
1289 genParameterType, secureRandomGenerator);
1290 }
1291
1292 /**
1293 * Configura de forma específica un algoritmo generador de JCEF
1294 *
1295 * @param algorithm
1296 * Algoritmo generador de JCEF
1297 * @param defaultGenParameter
1298 * Parámetro de configuración para
1299 * {@link Generator#setDefaultGenParameter(AlgorithmParameterSpec)}
1300 * @param availableGenParameters
1301 * Párametro de configuración para
1302 * {@link Generator#setAvailableGenParameters(AlgorithmParameterSpec[])}
1303 * @param genParameterType
1304 * Parámetro de configuración para
1305 * {@link Generator#setGenParameterType(Class)}
1306 * @param secureRandomGenerator
1307 * Parámetro de configuración para
1308 * {@link Generator#setSecureRandomGenerator(SecureRandomGenerator)}
1309 * @see Generator#setDefaultGenParameter(AlgorithmParameterSpec)
1310 * @see Generator#setAvailableGenParameters(AlgorithmParameterSpec[])
1311 * @see Generator#setGenParameterType(Class)
1312 * @see Generator#setSecureRandomGenerator(SecureRandomGenerator)
1313 */
1314 public static void configure_JCEF(Generator algorithm,
1315 AlgorithmParameterSpec defaultGenParameter,
1316 AlgorithmParameterSpec[] availableGenParameters,
1317 Class genParameterType, SecureRandomGenerator secureRandomGenerator) {
1318 algorithm.setDefaultGenParameter(defaultGenParameter);
1319 algorithm.setAvailableGenParameters(availableGenParameters);
1320 algorithm.setGenParameterType(genParameterType);
1321 algorithm.setSecureRandomGenerator(secureRandomGenerator);
1322 }
1323
1324 /**
1325 * Obtiene la configuración de un algoritmo generador de claves JCEF
1326 *
1327 * @param algorithm
1328 * Algoritmo generador de claves JCEF
1329 * @return Configuración
1330 * @see KeyGenerator#getDefaultKeySize()
1331 * @see KeyGenerator#getAvailableKeySizes()
1332 * @see KeyGenerator
1333 * @see #getConfiguration_JCEF(Generator)
1334 * @see #getConfiguration_JCEF(AsymmetricKeyGenerator)
1335 * @see #getConfiguration_JCEF(SymmetricKeyGenerator)
1336 */
1337 public static Map getConfiguration_JCEF(KeyGenerator algorithm) {
1338 Map result = getConfiguration_JCEF((Generator) algorithm);
1339 int defaultKeySize = algorithm.getDefaultKeySize();
1340 int[] availableKeySizes = algorithm.getAvailableKeySizes();
1341 result.put("defaultKeySize", new Integer(defaultKeySize));
1342 result.put("availableKeySizes", availableKeySizes);
1343
1344 return result;
1345 }
1346
1347 /**
1348 * Define la configuración de un algoritmo generador de claves JCEF
1349 *
1350 * @param algorithm
1351 * Algoritmo generador de claves
1352 * @param configuration
1353 * Configuración
1354 * @see #configure_JCEF(KeyGenerator, int, int[])
1355 * @see KeyGenerator
1356 * @see #setConfiguration_JCEF(Generator, Map)
1357 * @see #setConfiguration_JCEF(AsymmetricKeyGenerator, Map)
1358 * @see #setConfiguration_JCEF(SymmetricKeyGenerator, Map)
1359 */
1360 public static void setConfiguration_JCEF(KeyGenerator algorithm,
1361 Map configuration) {
1362 setConfiguration_JCEF((Generator) algorithm, configuration);
1363
1364 int defaultKeySize = ((Integer) configuration.get("defaultKeySize"))
1365 .intValue();
1366 int[] availableKeySizes = (int[]) configuration
1367 .get("availableKeySizes");
1368 configure_JCEF(algorithm, defaultKeySize, availableKeySizes);
1369 }
1370
1371 /**
1372 * Configura de forma específica un algoritmo generador de claves JCEF
1373 *
1374 * @param algorithm
1375 * Algoritmo generador de claves JCEF
1376 * @param defaultKeySize
1377 * Parámetro de configuración para
1378 * {@link KeyGenerator#setDefaultKeySize(int)}
1379 * @param availableKeySizes
1380 * Parámetro de configuración para
1381 * {@link KeyGenerator#setAvailableKeySizes(int[])}
1382 * @see KeyGenerator
1383 * @see KeyGenerator#setDefaultKeySize(int)
1384 * @see KeyGenerator#setAvailableKeySizes(int[])
1385 */
1386 public static void configure_JCEF(KeyGenerator algorithm,
1387 int defaultKeySize, int[] availableKeySizes) {
1388 algorithm.setDefaultKeySize(defaultKeySize);
1389 algorithm.setAvailableKeySizes(availableKeySizes);
1390 }
1391
1392 /**
1393 * Obtiene la configuración de un algoritmo generador de claves asimétricas
1394 * JCEF
1395 *
1396 * @param algorithm
1397 * Algoritmo generador de claves asimétricas JCEF
1398 * @return Configuración
1399 * @see AsymmetricKeyGenerator#getPrivateKeyType()
1400 * @see AsymmetricKeyGenerator#getPublicKeyType()
1401 * @see AsymmetricKeyGenerator
1402 * @see #getConfiguration_JCEF(KeyGenerator)
1403 * @see #getConfiguration_JCE(KeyPairGenerator)
1404 */
1405 public static Map getConfiguration_JCEF(AsymmetricKeyGenerator algorithm) {
1406 Map result = getConfiguration_JCEF((KeyGenerator) algorithm);
1407 Class privateKeyType = algorithm.getPrivateKeyType();
1408 Class publicKeyType = algorithm.getPublicKeyType();
1409 result.put("privateKeyType", privateKeyType);
1410 result.put("publicKeyType", publicKeyType);
1411
1412 return result;
1413 }
1414
1415 /**
1416 * Define la configuración de un algoritmo generador de claves asimétricas
1417 * JCEF
1418 *
1419 * @param algorithm
1420 * Algoritmo generador de claves asimétricas JCEF
1421 * @param configuration
1422 * Configuración
1423 * @see #configure_JCEF(AsymmetricKeyGenerator, Class, Class)
1424 * @see AsymmetricKeyGenerator
1425 * @see #setConfiguration_JCEF(KeyGenerator, Map)
1426 * @see #setConfiguration_JCE(KeyPairGenerator, Map)
1427 */
1428 public static void setConfiguration_JCEF(AsymmetricKeyGenerator algorithm,
1429 Map configuration) {
1430 setConfiguration_JCEF((KeyGenerator) algorithm, configuration);
1431
1432 Class privateKeyType = (Class) configuration.get("privateKeyType");
1433 Class publicKeyType = (Class) configuration.get("publicKeyType");
1434 configure_JCEF(algorithm, privateKeyType, publicKeyType);
1435 }
1436
1437 /**
1438 * Configura de forma específica un algoritmo generador de claves
1439 * asimétricas JCEF
1440 *
1441 * @param algorithm
1442 * Algoritmo generador de claves asimétricas JCEF
1443 * @param privateKeyType
1444 * Parámetro de configuración para
1445 * {@link AsymmetricKeyGenerator#setPrivateKeyType(Class)}
1446 * @param publicKeyType
1447 * Parámetro de configuración para
1448 * {@link AsymmetricKeyGenerator#setPublicKeyType(Class)}
1449 * @see AsymmetricKeyGenerator#setPrivateKeyType(Class)
1450 * @see AsymmetricKeyGenerator#setPublicKeyType(Class)
1451 * @see AsymmetricKeyGenerator
1452 */
1453 public static void configure_JCEF(AsymmetricKeyGenerator algorithm,
1454 Class privateKeyType, Class publicKeyType) {
1455 algorithm.setPrivateKeyType(privateKeyType);
1456 algorithm.setPublicKeyType(publicKeyType);
1457 }
1458
1459 /**
1460 * Obtiene la configuración de un algoritmo generador de claves asimétricas
1461 * JCE
1462 *
1463 * @param algorithm
1464 * Algoritmo generador de claves asimétricas JCE
1465 * @return Configuración
1466 * @see KeyPairGenerator
1467 * @see #getConfiguration_JCEF(AsymmetricKeyGenerator)
1468 */
1469 public static Map getConfiguration_JCE(KeyPairGenerator algorithm) {
1470 Map result = null;
1471
1472 return result;
1473 }
1474
1475 /**
1476 * Define la configuración de un algoritmo generador de claves asimétricas
1477 * JCE
1478 *
1479 * @param algorithm
1480 * Algoritmo generador de claves asimétricas JCE
1481 * @param configuration
1482 * Configuración
1483 * @see KeyPairGenerator
1484 * @see #setConfiguration_JCEF(AsymmetricKeyGenerator, Map)
1485 */
1486 public static void setConfiguration_JCE(KeyPairGenerator algorithm,
1487 Map configuration) {
1488 }
1489
1490 /**
1491 * Obtiene la configuración de un algoritmo generador de claves simétricas
1492 * JCEF
1493 *
1494 * @param algorithm
1495 * Algoritmo generador de claves simétricas JCEF
1496 * @return Configuración
1497 * @see SymmetricKeyGenerator#getSymmetricKeyType()
1498 * @see SymmetricKeyGenerator
1499 * @see #getConfiguration_JCEF(KeyGenerator)
1500 * @see #getConfiguration_JCE(javax.crypto.KeyGenerator)
1501 */
1502 public static Map getConfiguration_JCEF(SymmetricKeyGenerator algorithm) {
1503 Map result = getConfiguration_JCEF((KeyGenerator) algorithm);
1504 Class symmetricKeyType = algorithm.getSymmetricKeyType();
1505 result.put("symmetricKeyType", symmetricKeyType);
1506
1507 return result;
1508 }
1509
1510 /**
1511 * Define la configuración de un algoritmo generador de claves simétricas
1512 * JCEF
1513 *
1514 * @param algorithm
1515 * Algoritmo generador de claves simétricas JCEF
1516 * @param configuration
1517 * Configuración
1518 * @see #configure_JCEF(SymmetricKeyGenerator, Class)
1519 * @see SymmetricKeyGenerator
1520 * @see #setConfiguration_JCEF(KeyGenerator, Map)
1521 * @see #setConfiguration_JCE(javax.crypto.KeyGenerator, Map)
1522 */
1523 public static void setConfiguration_JCEF(SymmetricKeyGenerator algorithm,
1524 Map configuration) {
1525 setConfiguration_JCEF((KeyGenerator) algorithm, configuration);
1526
1527 Class symmetricKeyType = (Class) configuration.get("symmetricKeyType");
1528 configure_JCEF(algorithm, symmetricKeyType);
1529 }
1530
1531 /**
1532 * Configura de forma específica un algoritmo generador de claves simétricas
1533 * JCEF
1534 *
1535 * @param algorithm
1536 * Algoritmo generador de claves simétricas JCEF
1537 * @param symmetricKeyType
1538 * Parámetro de configuración para
1539 * {@link SymmetricKeyGenerator#setSymmetricKeyType(Class)}
1540 * @see SymmetricKeyGenerator#setSymmetricKeyType(Class)
1541 * @see SymmetricKeyGenerator
1542 */
1543 public static void configure_JCEF(SymmetricKeyGenerator algorithm,
1544 Class symmetricKeyType) {
1545 algorithm.setSymmetricKeyType(symmetricKeyType);
1546 }
1547
1548 /**
1549 * Obtiene la configuración de un algoritmo generador de claves simétricas
1550 * JCE
1551 *
1552 * @param algorithm
1553 * Algoritmo generador de claves simétricas JCE
1554 * @return Configuración
1555 * @see javax.crypto.KeyGenerator
1556 * @see #getConfiguration_JCEF(SymmetricKeyGenerator)
1557 */
1558 public static Map getConfiguration_JCE(javax.crypto.KeyGenerator algorithm) {
1559 Map result = null;
1560
1561 return result;
1562 }
1563
1564 /**
1565 * Define la configuración de un algoritmo generador de claves simétricas
1566 * JCE
1567 *
1568 * @param algorithm
1569 * Algoritmo generador de claves simétricas
1570 * @param configuration
1571 * Configuración
1572 * @see javax.crypto.KeyGenerator
1573 * @see #setConfiguration_JCEF(SymmetricKeyGenerator, Map)
1574 */
1575 public static void setConfiguration_JCE(
1576 javax.crypto.KeyGenerator algorithm, Map configuration) {
1577 }
1578
1579 /**
1580 * Obtiene la configuración de un algoritmo generador de parámetros JCEF
1581 *
1582 * @param algorithm
1583 * Algoritmo generador de parámetros JCEF
1584 * @return Configuración
1585 * @see ParameterGenerator#getDefaultParameterSize()
1586 * @see ParameterGenerator#getAvailableParameterSizes()
1587 * @see ParameterGenerator
1588 * @see #getConfiguration_JCEF(Generator)
1589 * @see #getConfiguration_JCE(AlgorithmParameterGenerator)
1590 */
1591 public static Map getConfiguration_JCEF(ParameterGenerator algorithm) {
1592 Map result = getConfiguration_JCEF((Generator) algorithm);
1593 int defaultParameterSize = algorithm.getDefaultParameterSize();
1594 int[] availableParameterSizes = algorithm.getAvailableParameterSizes();
1595 result.put("defaultParameterSize", new Integer(defaultParameterSize));
1596 result.put("availableParameterSizes", availableParameterSizes);
1597
1598 return result;
1599 }
1600
1601 /**
1602 * Define la configuración de un algoritmo generador de parámetros JCEF
1603 *
1604 * @param algorithm
1605 * Algoritmo generador de parámetros JCEF
1606 * @param configuration
1607 * Configuración
1608 * @see #configure_JCEF(ParameterGenerator, int, int[])
1609 * @see ParameterGenerator
1610 * @see #setConfiguration_JCEF(Generator, Map)
1611 * @see #setConfiguration_JCE(AlgorithmParameterGenerator, Map)
1612 */
1613 public static void setConfiguration_JCEF(ParameterGenerator algorithm,
1614 Map configuration) {
1615 setConfiguration_JCEF((Generator) algorithm, configuration);
1616
1617 int defaultParameterSize = ((Integer) configuration
1618 .get("defaultParameterSize")).intValue();
1619 int[] availableParameterSizes = (int[]) configuration
1620 .get("availableParameterSizes");
1621 configure_JCEF(algorithm, defaultParameterSize, availableParameterSizes);
1622 }
1623
1624 /**
1625 * Configura de forma específica un algoritmo generador de parámetros JCEF
1626 *
1627 * @param algorithm
1628 * Algoritmo generador de parámetros JCEF
1629 * @param defaultParameterSize
1630 * Parámetro de configuración para
1631 * {@link ParameterGenerator#setDefaultParameterSize(int)}
1632 * @param availableParameterSizes
1633 * Parámetro de configuración para
1634 * {@link ParameterGenerator#setAvailableParameterSizes(int[])}
1635 * @see ParameterGenerator#setDefaultParameterSize(int)
1636 * @see ParameterGenerator#setAvailableParameterSizes(int[])
1637 * @see ParameterGenerator
1638 */
1639 public static void configure_JCEF(ParameterGenerator algorithm,
1640 int defaultParameterSize, int[] availableParameterSizes) {
1641 algorithm.setDefaultParameterSize(defaultParameterSize);
1642 algorithm.setAvailableParameterSizes(availableParameterSizes);
1643 }
1644
1645 /**
1646 * Obtiene la configuración de un algoritmo generador de parámetros JCE
1647 *
1648 * @param algorithm
1649 * Algoritmo generador de parámetros JCE
1650 * @return Configuración
1651 * @see AlgorithmParameterGenerator
1652 * @see #getConfiguration_JCEF(ParameterGenerator)
1653 */
1654 public static Map getConfiguration_JCE(AlgorithmParameterGenerator algorithm) {
1655 Map result = null;
1656
1657 return result;
1658 }
1659
1660 /**
1661 * Define la configuración de un algoritmo generador de parámetros JCE
1662 *
1663 * @param algorithm
1664 * Algoritmo generador de parámetros JCE
1665 * @param configuration
1666 * Configuración
1667 * @see AlgorithmParameterGenerator
1668 * @see #setConfiguration_JCEF(ParameterGenerator, Map)
1669 */
1670 public static void setConfiguration_JCE(
1671 AlgorithmParameterGenerator algorithm, Map configuration) {
1672 }
1673
1674 /**
1675 * Obtiene la configuración de un algoritmo generador de datos aleatorios
1676 * JCEF
1677 *
1678 * @param algorithm
1679 * Algoritmo generador de datos aleatorios JCEF
1680 * @return Configuración
1681 * @see SecureRandomGenerator
1682 * @see #getConfiguration_JCEF(Generator)
1683 * @see #getConfiguration_JCE(SecureRandom)
1684 */
1685 public static Map getConfiguration_JCEF(SecureRandomGenerator algorithm) {
1686 Map result = getConfiguration_JCEF((Generator) algorithm);
1687
1688 return result;
1689 }
1690
1691 /**
1692 * Define la configuración de un algoritmo generador de datos aleatorios
1693 * JCEF
1694 *
1695 * @param algorithm
1696 * Algoritmo generador de datos aleatorios JCEF
1697 * @param configuration
1698 * Configuración
1699 * @see #configure_JCEF(SecureRandomGenerator)
1700 * @see SecureRandomGenerator
1701 * @see #setConfiguration_JCE(SecureRandom, Map)
1702 */
1703 public static void setConfiguration_JCEF(SecureRandomGenerator algorithm,
1704 Map configuration) {
1705 setConfiguration_JCEF((Generator) algorithm, configuration);
1706 configure_JCEF(algorithm);
1707 }
1708
1709 /**
1710 * Configura de forma específica un algoritmo generador de datos aleatorios
1711 * JCEF
1712 *
1713 * @param algorithm
1714 * Algoritmo generador de datos aleatorios JCEF
1715 * @see SecureRandomGenerator
1716 * @see #setConfiguration_JCEF(SecureRandomGenerator, Map)
1717 */
1718 public static void configure_JCEF(SecureRandomGenerator algorithm) {
1719 }
1720
1721 /**
1722 * Obtiene la configuración de un algoritmo generador de datos aleatorios
1723 * JCE
1724 *
1725 * @param algorithm
1726 * Algoritmo generador de datos aleatorios JCE
1727 * @return Configuración
1728 * @see SecureRandom
1729 * @see #getConfiguration_JCEF(SecureRandomGenerator)
1730 */
1731 public static Map getConfiguration_JCE(SecureRandom algorithm) {
1732 Map result = null;
1733
1734 return result;
1735 }
1736
1737 /**
1738 * Define la configuración de un algoritmo generador de datos aleatorios JCE
1739 *
1740 * @param algorithm
1741 * Algoritmo generador de datos aleatorios JCE
1742 * @param configuration
1743 * Configuración
1744 * @see SecureRandom
1745 * @see #setConfiguration_JCEF(SecureRandomGenerator, Map)
1746 */
1747 public static void setConfiguration_JCE(SecureRandom algorithm,
1748 Map configuration) {
1749 }
1750
1751 /**
1752 * Obtiene la configuración de un algoritmo traductor JCEF
1753 *
1754 * @param algorithm
1755 * Algoritmo traductor JCEF
1756 * @return Configuración
1757 * @see Translator
1758 * @see #getConfiguration_JCEF(Algorithm)
1759 * @see #getConfiguration_JCEF(KeyTranslator)
1760 * @see #getConfiguration_JCEF(ParameterTranslator)
1761 */
1762 public static Map getConfiguration_JCEF(Translator algorithm) {
1763 Map result = getConfiguration_JCEF((Algorithm) algorithm);
1764
1765 return result;
1766 }
1767
1768 /**
1769 * Define la configuración de un algoritmo traductor JCEF
1770 *
1771 * @param algorithm
1772 * Algoritmo traductor JCEF
1773 * @param configuration
1774 * Configuración
1775 * @see #configure_JCEF(Translator)
1776 * @see Translator
1777 * @see #setConfiguration_JCEF(Algorithm, Map)
1778 * @see #setConfiguration_JCEF(KeyTranslator, Map)
1779 * @see #setConfiguration_JCEF(ParameterTranslator, Map)
1780 */
1781 public static void setConfiguration_JCEF(Translator algorithm,
1782 Map configuration) {
1783 setConfiguration_JCEF((Algorithm) algorithm, configuration);
1784 configure_JCEF(algorithm);
1785 }
1786
1787 /**
1788 * Configura de forma específica un algoritmo traductor JCEF
1789 *
1790 * @param algorithm
1791 * Algoritmo traductor JCEF
1792 * @see Translator
1793 * @see #setConfiguration_JCEF(Translator, Map)
1794 */
1795 public static void configure_JCEF(Translator algorithm) {
1796 }
1797
1798 /**
1799 * Obtiene la configuración de un algoritmo traductor de claves JCEF
1800 *
1801 * @param algorithm
1802 * Algoritmo traductor de claves JCEF
1803 * @return Configuración
1804 * @see KeyTranslator
1805 * @see #getConfiguration_JCEF(Translator)
1806 * @see #getConfiguration_JCEF(AsymmetricKeyTranslator)
1807 * @see #getConfiguration_JCEF(SymmetricKeyTranslator)
1808 */
1809 public static Map getConfiguration_JCEF(KeyTranslator algorithm) {
1810 Map result = getConfiguration_JCEF((Translator) algorithm);
1811
1812 return result;
1813 }
1814
1815 /**
1816 * Define la configuración de un algoritmo traductor de claves JCEF
1817 *
1818 * @param algorithm
1819 * Algoritmo traductor de claves JCEF
1820 * @param configuration
1821 * Configuración
1822 * @see #configure_JCEF(KeyTranslator)
1823 * @see KeyTranslator
1824 * @see #setConfiguration_JCEF(Translator, Map)
1825 * @see #setConfiguration_JCEF(AsymmetricKeyTranslator, Map)
1826 * @see #setConfiguration_JCEF(SymmetricKeyTranslator, Map)
1827 */
1828 public static void setConfiguration_JCEF(KeyTranslator algorithm,
1829 Map configuration) {
1830 setConfiguration_JCEF((Translator) algorithm, configuration);
1831 configure_JCEF(algorithm);
1832 }
1833
1834 /**
1835 * Configura de forma específica un algoritmo traductor de claves JCEF
1836 *
1837 * @param algorithm
1838 * Algoritmo traductor de claves JCEF
1839 * @see #setConfiguration_JCEF(KeyTranslator, Map)
1840 */
1841 public static void configure_JCEF(KeyTranslator algorithm) {
1842 }
1843
1844 /**
1845 * Obtiene la configuración de un algoritmo traductor de claves asimétricas
1846 * JCEF
1847 *
1848 * @param algorithm
1849 * Algoritmo traductor de claves asimétricas JCEF
1850 * @return Configuración
1851 * @see AsymmetricKeyTranslator#getPrivateKeyType()
1852 * @see AsymmetricKeyTranslator#getPrivateKeySpecType()
1853 * @see AsymmetricKeyTranslator#getUnknownPrivateKeyTypes()
1854 * @see AsymmetricKeyTranslator#getPublicKeyType()
1855 * @see AsymmetricKeyTranslator#getPublicKeySpecType()
1856 * @see AsymmetricKeyTranslator#getUnknownPublicKeyTypes()
1857 * @see AsymmetricKeyTranslator
1858 * @see #getConfiguration_JCEF(KeyTranslator)
1859 * @see #getConfiguration_JCE(KeyFactory)
1860 */
1861 public static Map getConfiguration_JCEF(AsymmetricKeyTranslator algorithm) {
1862 Map result = getConfiguration_JCEF((KeyTranslator) algorithm);
1863 Class privateKeySpecType = algorithm.getPrivateKeySpecType();
1864 Class publicKeySpecType = algorithm.getPublicKeySpecType();
1865 Class privateKeyType = algorithm.getPrivateKeyType();
1866 Class publicKeyType = algorithm.getPublicKeyType();
1867 Class[] unknownPrivateKeyTypes = algorithm.getUnknownPrivateKeyTypes();
1868 Class[] unknownPublicKeyTypes = algorithm.getUnknownPublicKeyTypes();
1869 result.put("privateKeySpecType", privateKeySpecType);
1870 result.put("publicKeySpecType", publicKeySpecType);
1871 result.put("privateKeyType", privateKeyType);
1872 result.put("publicKeyType", publicKeyType);
1873 result.put("unknownPrivateKeyTypes", unknownPrivateKeyTypes);
1874 result.put("unknownPublicKeyTypes", unknownPublicKeyTypes);
1875
1876 return result;
1877 }
1878
1879 /**
1880 * Define la configuración de un algoritmo traductor de claves asimétricas
1881 * JCEF
1882 *
1883 * @param algorithm
1884 * Algoritmo traductor de claves asimétricas JCEF
1885 * @param configuration
1886 * Configuración
1887 * @see #configure_JCEF(AsymmetricKeyTranslator, Class, Class, Class[],
1888 * Class, Class, Class[])
1889 * @see AsymmetricKeyTranslator
1890 * @see #setConfiguration_JCEF(KeyTranslator, Map)
1891 * @see #setConfiguration_JCE(KeyFactory, Map)
1892 */
1893 public static void setConfiguration_JCEF(AsymmetricKeyTranslator algorithm,
1894 Map configuration) {
1895 setConfiguration_JCEF((KeyTranslator) algorithm, configuration);
1896
1897 Class privateKeyType = (Class) configuration.get("privateKeyType");
1898 Class privateKeySpecType = (Class) configuration
1899 .get("privateKeySpecType");
1900 Class[] unknownPrivateKeyTypes = (Class[]) configuration
1901 .get("unknownPrivateKeyTypes");
1902 Class publicKeyType = (Class) configuration.get("publicKeyType");
1903 Class publicKeySpecType = (Class) configuration
1904 .get("publicKeySpecType");
1905 Class[] unknownPublicKeyTypes = (Class[]) configuration
1906 .get("unknownPublicKeyTypes");
1907 configure_JCEF(algorithm, privateKeyType, privateKeySpecType,
1908 unknownPrivateKeyTypes, publicKeyType, publicKeySpecType,
1909 unknownPublicKeyTypes);
1910 }
1911
1912 /**
1913 * Configura de forma específica un algoritmo traductor de claves
1914 * asimétricas JCEF
1915 *
1916 * @param algorithm
1917 * Algoritmo traductor de claves asimétricas JCEF
1918 * @param privateKeyType
1919 * Parámetro de configuración para
1920 * {@link AsymmetricKeyTranslator#setPrivateKeyType(Class)}
1921 * @param privateKeySpecType
1922 * Parámetro de configuración para
1923 * {@link AsymmetricKeyTranslator#setPrivateKeySpecType(Class)}
1924 * @param unknownPrivateKeyTypes
1925 * Parámetro de configuración para
1926 * {@link AsymmetricKeyTranslator#setUnknownPrivateKeyTypes(Class[])}
1927 * @param publicKeyType
1928 * Parámetro de configuración para
1929 * {@link AsymmetricKeyTranslator#setPublicKeyType(Class)}
1930 * @param publicKeySpecType
1931 * Parámetro de configuración para
1932 * {@link AsymmetricKeyTranslator#setPublicKeySpecType(Class)}
1933 * @param unknownPublicKeyTypes
1934 * Parámetro de configuración para
1935 * {@link AsymmetricKeyTranslator#setUnknownPublicKeyTypes(Class[])}
1936 * @see AsymmetricKeyTranslator#setPrivateKeyType(Class)
1937 * @see AsymmetricKeyTranslator#setPrivateKeySpecType(Class)
1938 * @see AsymmetricKeyTranslator#setUnknownPrivateKeyTypes(Class[])
1939 * @see AsymmetricKeyTranslator#setPublicKeyType(Class)
1940 * @see AsymmetricKeyTranslator#setPublicKeySpecType(Class)
1941 * @see AsymmetricKeyTranslator#setUnknownPublicKeyTypes(Class[])
1942 */
1943 public static void configure_JCEF(AsymmetricKeyTranslator algorithm,
1944 Class privateKeyType, Class privateKeySpecType,
1945 Class[] unknownPrivateKeyTypes, Class publicKeyType,
1946 Class publicKeySpecType, Class[] unknownPublicKeyTypes) {
1947 algorithm.setPrivateKeyType(privateKeyType);
1948 algorithm.setPrivateKeySpecType(privateKeySpecType);
1949 algorithm.setUnknownPrivateKeyTypes(unknownPrivateKeyTypes);
1950 algorithm.setPublicKeyType(publicKeyType);
1951 algorithm.setPublicKeySpecType(publicKeySpecType);
1952 algorithm.setUnknownPublicKeyTypes(unknownPublicKeyTypes);
1953 }
1954
1955 /**
1956 * Obtiene la configuración de un algoritmo traductor de claves asimétricas
1957 * JCE
1958 *
1959 * @param algorithm
1960 * Algoritmo traductor de claves asimétricas JCE
1961 * @return Configuración
1962 * @see KeyFactory
1963 * @see #getConfiguration_JCEF(AsymmetricKeyTranslator)
1964 */
1965 public static Map getConfiguration_JCE(KeyFactory algorithm) {
1966 Map result = null;
1967
1968 return result;
1969 }
1970
1971 /**
1972 * Define la configuración de un algoritmo traductor de claves asimétricas
1973 * JCE
1974 *
1975 * @param algorithm
1976 * Algoritmo traductor de claves asimétricas JCE
1977 * @param configuration
1978 * Configuración
1979 * @see KeyFactory
1980 * @see #setConfiguration_JCEF(AsymmetricKeyTranslator, Map)
1981 */
1982 public static void setConfiguration_JCE(KeyFactory algorithm,
1983 Map configuration) {
1984 }
1985
1986 /**
1987 * Obtiene la configuración de un algoritmo traductor de claves simétricas
1988 * JCEF
1989 *
1990 * @param algorithm
1991 * Algoritmo traductor de claves simétricas JCEF
1992 * @return Configuración
1993 * @see SymmetricKeyTranslator#getSymmetricKeyType()
1994 * @see SymmetricKeyTranslator#getSymmetricKeySpecType()
1995 * @see SymmetricKeyTranslator#getUnknownSymmetricKeyTypes()
1996 * @see SymmetricKeyTranslator
1997 * @see #getConfiguration_JCEF(KeyTranslator)
1998 * @see #getConfiguration_JCE(SecretKeyFactory)
1999 */
2000 public static Map getConfiguration_JCEF(SymmetricKeyTranslator algorithm) {
2001 Map result = getConfiguration_JCEF((KeyTranslator) algorithm);
2002 Class symmetricKeyType = algorithm.getSymmetricKeyType();
2003 Class symmetricKeySpecType = algorithm.getSymmetricKeySpecType();
2004 Class[] unknownSymmetricKeyTypes = algorithm
2005 .getUnknownSymmetricKeyTypes();
2006 result.put("symmetricKeyType", symmetricKeyType);
2007 result.put("symmetricKeySpecType", symmetricKeySpecType);
2008 result.put("unknownSymmetricKeyTypes", unknownSymmetricKeyTypes);
2009
2010 return result;
2011 }
2012
2013 /**
2014 * Define la configuración de un algoritmo traductor de claves simétricas
2015 * JCEF
2016 *
2017 * @param algorithm
2018 * Algoritmo traductor de claves simétricas JCEF
2019 * @param configuration
2020 * Configuración
2021 * @see #configure_JCEF(SymmetricKeyTranslator, Class, Class, Class[])
2022 * @see SymmetricKeyTranslator
2023 * @see #setConfiguration_JCEF(KeyTranslator, Map)
2024 * @see #setConfiguration_JCE(SecretKeyFactory, Map)
2025 */
2026 public static void setConfiguration_JCEF(SymmetricKeyTranslator algorithm,
2027 Map configuration) {
2028 setConfiguration_JCEF((KeyTranslator) algorithm, configuration);
2029
2030 Class symmetricKeyType = (Class) configuration.get("symmetricKeyType");
2031 Class symmetricKeySpecType = (Class) configuration
2032 .get("symmetricKeySpecType");
2033 Class[] unknownSymmetricKeyTypes = (Class[]) configuration
2034 .get("unknownSymmetricKeyTypes");
2035 configure_JCEF(algorithm, symmetricKeyType, symmetricKeySpecType,
2036 unknownSymmetricKeyTypes);
2037 }
2038
2039 /**
2040 * Configura de forma específica un algoritmo traductor de claves simétricas
2041 * JCEF
2042 *
2043 * @param algorithm
2044 * Algoritmo traductor de claves simétricas JCEF
2045 * @param symmetricKeyType
2046 * Parámetro de configuración para
2047 * {@link SymmetricKeyTranslator#setSymmetricKeyType(Class)}
2048 * @param symmetricKeySpecType
2049 * Parámetro de configuración para
2050 * {@link SymmetricKeyTranslator#setSymmetricKeySpecType(Class)}
2051 * @param unknownSymmetricKeyTypes
2052 * Parámetro de configuración para
2053 * {@link SymmetricKeyTranslator#setUnknownSymmetricKeyTypes(Class[])}
2054 * @see SymmetricKeyTranslator#setSymmetricKeyType(Class)
2055 * @see SymmetricKeyTranslator#setSymmetricKeySpecType(Class)
2056 * @see SymmetricKeyTranslator#setUnknownSymmetricKeyTypes(Class[])
2057 * @see SymmetricKeyTranslator
2058 * @see #setConfiguration_JCEF(SymmetricKeyTranslator, Map)
2059 */
2060 public static void configure_JCEF(SymmetricKeyTranslator algorithm,
2061 Class symmetricKeyType, Class symmetricKeySpecType,
2062 Class[] unknownSymmetricKeyTypes) {
2063 algorithm.setSymmetricKeyType(symmetricKeyType);
2064 algorithm.setSymmetricKeySpecType(symmetricKeySpecType);
2065 algorithm.setUnknownSymmetricKeyTypes(unknownSymmetricKeyTypes);
2066 }
2067
2068 /**
2069 * Obtiene la configuración de un algoritmo traductor de claves simétricas
2070 * JCE
2071 *
2072 * @param algorithm
2073 * Algoritmo traductor de claves simétricas JCE
2074 * @return Configuración
2075 * @see SecretKeyFactory
2076 * @see #getConfiguration_JCEF(SymmetricKeyTranslator)
2077 */
2078 public static Map getConfiguration_JCE(SecretKeyFactory algorithm) {
2079 Map result = null;
2080
2081 return result;
2082 }
2083
2084 /**
2085 * Define la configuración de un algoritmo traductor de claves simétricas
2086 * JCE
2087 *
2088 * @param algorithm
2089 * Algoritmo traductor de claves simétricas JCE
2090 * @param configuration
2091 * Configuración
2092 * @see SecretKeyFactory
2093 * @see #setConfiguration_JCEF(SymmetricKeyTranslator, Map)
2094 */
2095 public static void setConfiguration_JCE(SecretKeyFactory algorithm,
2096 Map configuration) {
2097 }
2098
2099 /**
2100 * Obtiene la configuración de un algoritmo traductor de parámetros JCEF
2101 *
2102 * @param algorithm
2103 * Algoritmo traductor de parámetros JCEF
2104 * @return Configuración
2105 * @see ParameterTranslator#getParameterType()
2106 * @see ParameterTranslator#getAvailableFormat()
2107 * @see ParameterTranslator
2108 * @see #getConfiguration_JCEF(Translator)
2109 * @see #getConfiguration_JCE(AlgorithmParameters)
2110 */
2111 public static Map getConfiguration_JCEF(ParameterTranslator algorithm) {
2112 Map result = getConfiguration_JCEF((Translator) algorithm);
2113 String availableFormat = algorithm.getAvailableFormat();
2114 Class parameterType = algorithm.getParameterType();
2115 result.put("parameterType", parameterType);
2116 result.put("availableFormat", availableFormat);
2117
2118 return result;
2119 }
2120
2121 /**
2122 * Define la configuración de un algoritmo traductor de parámetros JCEF
2123 *
2124 * @param algorithm
2125 * Algoritmo traductor de parámetros JCEF
2126 * @param configuration
2127 * Configuración
2128 * @see #configure_JCEF(ParameterTranslator, Class, String)
2129 * @see ParameterTranslator
2130 * @see #setConfiguration_JCEF(Translator, Map)
2131 * @see #setConfiguration_JCE(AlgorithmParameters, Map)
2132 */
2133 public static void setConfiguration_JCEF(ParameterTranslator algorithm,
2134 Map configuration) {
2135 setConfiguration_JCEF((Translator) algorithm, configuration);
2136
2137 Class parameterType = (Class) configuration.get("parameterType");
2138 String availableFormat = (String) configuration.get("availableFormat");
2139 configure_JCEF(algorithm, parameterType, availableFormat);
2140 }
2141
2142 /**
2143 * Configura de forma específica un algoritmo traductor de parámetros JCEF
2144 *
2145 * @param algorithm
2146 * Algoritmo traductor de parámetros JCEF
2147 * @param parameterType
2148 * Parámetro de configuración para
2149 * {@link ParameterTranslator#setParameterType(Class)}
2150 * @param availableFormat
2151 * Parámetro de configuración para
2152 * {@link ParameterTranslator#setAvailableFormat(String)}
2153 * @see ParameterTranslator#setParameterType(Class)
2154 * @see ParameterTranslator#setAvailableFormat(String)
2155 */
2156 public static void configure_JCEF(ParameterTranslator algorithm,
2157 Class parameterType, String availableFormat) {
2158 algorithm.setParameterType(parameterType);
2159 algorithm.setAvailableFormat(availableFormat);
2160 }
2161
2162 /**
2163 * Obtiene la configuración de un algoritmo traductor de parámetros JCE
2164 *
2165 * @param algorithm
2166 * Algoritmo traductor de parámetros JCE
2167 * @return Configuración
2168 * @see AlgorithmParameters
2169 * @see #getConfiguration_JCEF(ParameterTranslator)
2170 */
2171 public static Map getConfiguration_JCE(AlgorithmParameters algorithm) {
2172 Map result = null;
2173
2174 return result;
2175 }
2176
2177 /**
2178 * Define la configuración de un algoritmo traductor de parámetros JCE
2179 *
2180 * @param algorithm
2181 * Algoritmo traductor de parámetros JCE
2182 * @param configuration
2183 * Configuración
2184 * @see AlgorithmParameters
2185 * @see #setConfiguration_JCEF(ParameterTranslator, Map)
2186 */
2187 public static void setConfiguration_JCE(AlgorithmParameters algorithm,
2188 Map configuration) {
2189 }
2190
2191 /**
2192 * Obtiene la configuración de un algoritmo criptográfico JCEF
2193 *
2194 * @param algorithm
2195 * Algoritmo criptográfico JCEF
2196 * @return Configuración
2197 * @see CryptoAlgorithm#getDefaultParameter()
2198 * @see CryptoAlgorithm#getAvailableParameters()
2199 * @see CryptoAlgorithm#getParameterType()
2200 * @see CryptoAlgorithm#getParameterGenerator()
2201 * @see CryptoAlgorithm#getParameterTranslator()
2202 * @see CryptoAlgorithm
2203 * @see #getConfiguration_JCEF(Algorithm)
2204 * @see #getConfiguration_JCEF(AuthenticationAlgorithm)
2205 * @see #getConfiguration_JCEF(Protection)
2206 */
2207 public static Map getConfiguration_JCEF(CryptoAlgorithm algorithm) {
2208 Map result = getConfiguration_JCEF((Algorithm) algorithm);
2209 AlgorithmParameterSpec defaultParameter = algorithm
2210 .getDefaultParameter();
2211 AlgorithmParameterSpec[] availableParameters = algorithm
2212 .getAvailableParameters();
2213 Class parameterType = algorithm.getParameterType();
2214 ParameterTranslator parameterTranslator = algorithm
2215 .getParameterTranslator();
2216 ParameterGenerator parameterGenerator = algorithm
2217 .getParameterGenerator();
2218 result.put("defaultParameter", defaultParameter);
2219 result.put("availableParameters", availableParameters);
2220 result.put("parameterType", parameterType);
2221 result.put("parameterTranslator", parameterTranslator);
2222 result.put("parameterGenerator", parameterGenerator);
2223
2224 return result;
2225 }
2226
2227 /**
2228 * Define la configuración de un algoritmo criptográfico JCEF
2229 *
2230 * @param algorithm
2231 * Algoritmo criptográfico JCEF
2232 * @param configuration
2233 * Configuración
2234 * @see #configure_JCEF(CryptoAlgorithm, AlgorithmParameterSpec,
2235 * AlgorithmParameterSpec[], Class, ParameterGenerator,
2236 * ParameterTranslator)
2237 * @see CryptoAlgorithm
2238 * @see #setConfiguration_JCEF(Algorithm, Map)
2239 * @see #setConfiguration_JCEF(AuthenticationAlgorithm, Map)
2240 * @see #setConfiguration_JCEF(Protection, Map)
2241 */
2242 public static void setConfiguration_JCEF(CryptoAlgorithm algorithm,
2243 Map configuration) {
2244 setConfiguration_JCEF((Algorithm) algorithm, configuration);
2245
2246 AlgorithmParameterSpec defaultParameter = (AlgorithmParameterSpec) configuration
2247 .get("defaultParameter");
2248 AlgorithmParameterSpec[] availableParameters = (AlgorithmParameterSpec[]) configuration
2249 .get("availableParameters");
2250 Class parameterType = (Class) configuration.get("parameterType");
2251 ParameterGenerator parameterGenerator = (ParameterGenerator) configuration
2252 .get("parameterGenerator");
2253 ParameterTranslator parameterTranslator = (ParameterTranslator) configuration
2254 .get("parameterTranslator");
2255 configure_JCEF(algorithm, defaultParameter, availableParameters,
2256 parameterType, parameterGenerator, parameterTranslator);
2257 }
2258
2259 /**
2260 * Configura de forma específica un algoritmo criptográfico JCEF
2261 *
2262 * @param algorithm
2263 * Algoritmo criptográfico JCEF
2264 * @param defaultParameter
2265 * Parámetro de configuración para
2266 * {@link CryptoAlgorithm#setDefaultParameter(AlgorithmParameterSpec)}
2267 * @param availableParameters
2268 * Parámetro de configuración para
2269 * {@link CryptoAlgorithm#setAvailableParameters(AlgorithmParameterSpec[])}
2270 * @param parameterType
2271 * Parámetro de configuración para
2272 * {@link CryptoAlgorithm#setParameterType(Class)}
2273 * @param parameterGenerator
2274 * Parámetro de configuración para
2275 * {@link CryptoAlgorithm#setParameterGenerator(ParameterGenerator)}
2276 * @param parameterTranslator
2277 * Parámetro de configuración para
2278 * {@link CryptoAlgorithm#setParameterTranslator(ParameterTranslator)}
2279 * @see CryptoAlgorithm#setDefaultParameter(AlgorithmParameterSpec)
2280 * @see CryptoAlgorithm#setAvailableParameters(AlgorithmParameterSpec[])
2281 * @see CryptoAlgorithm#setParameterType(Class)
2282 * @see CryptoAlgorithm#setParameterGenerator(ParameterGenerator)
2283 * @see CryptoAlgorithm#setParameterTranslator(ParameterTranslator)
2284 * @see #setConfiguration_JCEF(CryptoAlgorithm, Map)
2285 */
2286 public static void configure_JCEF(CryptoAlgorithm algorithm,
2287 AlgorithmParameterSpec defaultParameter,
2288 AlgorithmParameterSpec[] availableParameters, Class parameterType,
2289 ParameterGenerator parameterGenerator,
2290 ParameterTranslator parameterTranslator) {
2291 algorithm.setDefaultParameter(defaultParameter);
2292 algorithm.setAvailableParameters(availableParameters);
2293 algorithm.setParameterType(parameterType);
2294 algorithm.setParameterGenerator(parameterGenerator);
2295 algorithm.setParameterTranslator(parameterTranslator);
2296 }
2297
2298 /**
2299 * Obtiene la configuración de un algoritmo criptográfico de autentificación
2300 * JCEF
2301 *
2302 * @param algorithm
2303 * Algoritmo criptográfico de autentificación JCEF
2304 * @return Configuración
2305 * @see AuthenticationAlgorithm#getAuthenticatorLength()
2306 * @see AuthenticationAlgorithm
2307 * @see #getConfiguration_JCEF(CryptoAlgorithm)
2308 * @see #getConfiguration_JCEF(FingerPrint)
2309 * @see #getConfiguration_JCEF(DigitalSeal)
2310 * @see #getConfiguration_JCEF(DigitalSignature)
2311 */
2312 public static Map getConfiguration_JCEF(AuthenticationAlgorithm algorithm) {
2313 Map result = getConfiguration_JCEF((CryptoAlgorithm) algorithm);
2314 int authenticatorLength = algorithm.getAuthenticatorLength();
2315 result.put("authenticatorLength", new Integer(authenticatorLength));
2316
2317 return result;
2318 }
2319
2320 /**
2321 * Define la configuración de un algoritmo criptográfico de autentificación
2322 * JCEF
2323 *
2324 * @param algorithm
2325 * Algoritmo criptográfico de autentificación JCEF
2326 * @param configuration
2327 * Configuración
2328 * @see #configure_JCEF(AuthenticationAlgorithm, int)
2329 * @see AuthenticationAlgorithm
2330 * @see #setConfiguration_JCEF(CryptoAlgorithm, Map)
2331 * @see #setConfiguration_JCEF(FingerPrint, Map)
2332 * @see #setConfiguration_JCEF(DigitalSeal, Map)
2333 * @see #setConfiguration_JCEF(DigitalSignature, Map)
2334 */
2335 public static void setConfiguration_JCEF(AuthenticationAlgorithm algorithm,
2336 Map configuration) {
2337 setConfiguration_JCEF((CryptoAlgorithm) algorithm, configuration);
2338
2339 int authenticatorLength = ((Integer) configuration
2340 .get("authenticatorLength")).intValue();
2341 configure_JCEF(algorithm, authenticatorLength);
2342 }
2343
2344 /**
2345 * Configura de forma específica un algoritmo criptográfico de
2346 * autentificación
2347 *
2348 * @param algorithm
2349 * Algoritmo criptográfico de autentificación
2350 * @param authenticatorLength
2351 * Parámetro de configuración para
2352 * {@link AuthenticationAlgorithm#setAuthenticatorLength(int)}
2353 * @see AuthenticationAlgorithm#setAuthenticatorLength(int)
2354 * @see AuthenticationAlgorithm
2355 * @see #setConfiguration_JCEF(AuthenticationAlgorithm, Map)
2356 */
2357 public static void configure_JCEF(AuthenticationAlgorithm algorithm,
2358 int authenticatorLength) {
2359 algorithm.setAuthenticatorLength(authenticatorLength);
2360 }
2361
2362 /**
2363 * Obtiene la configuración de un algoritmo criptográfico de autentificación
2364 * de huellas digitales JCEF
2365 *
2366 * @param algorithm
2367 * Algoritmo criptográfico de autentificación de huellas
2368 * digitales JCEF
2369 * @return Configuración
2370 * @see FingerPrint
2371 * @see #getConfiguration_JCEF(AuthenticationAlgorithm)
2372 * @see #getConfiguration_JCE(MessageDigest)
2373 */
2374 public static Map getConfiguration_JCEF(FingerPrint algorithm) {
2375 Map result = getConfiguration_JCEF((AuthenticationAlgorithm) algorithm);
2376
2377 return result;
2378 }
2379
2380 /**
2381 * Define la configuración de un algoritmo criptográfico de autentificación
2382 * de huellas digitales JCEF
2383 *
2384 * @param algorithm
2385 * Algoritmo criptográfico de autentificación de huellas
2386 * digitales JCEF
2387 * @param configuration
2388 * Configuración
2389 * @see #configure_JCEF(FingerPrint)
2390 * @see FingerPrint
2391 * @see #setConfiguration_JCEF(AuthenticationAlgorithm, Map)
2392 * @see #setConfiguration_JCE(MessageDigest, Map)
2393 */
2394 public static void setConfiguration_JCEF(FingerPrint algorithm,
2395 Map configuration) {
2396 setConfiguration_JCEF((AuthenticationAlgorithm) algorithm,
2397 configuration);
2398 configure_JCEF(algorithm);
2399 }
2400
2401 /**
2402 * Configura de forma específica un algoritmo criptográfico de
2403 * autentificación de huellas digitales JCEF
2404 *
2405 * @param algorithm
2406 * Algoritmo criptográfico de autentificación de huellas
2407 * digitales JCEF
2408 */
2409 public static void configure_JCEF(FingerPrint algorithm) {
2410 }
2411
2412 /**
2413 * Obtiene la configuración de un algoritmo criptográfico de autentificación
2414 * de huellas digitales JCE
2415 *
2416 * @param algorithm
2417 * Algoritmo criptográfico de autentificación de huellas
2418 * digitales JCE
2419 * @return Configuración
2420 * @see MessageDigest#getDigestLength()
2421 * @see MessageDigest
2422 * @see #getConfiguration_JCEF(FingerPrint)
2423 */
2424 public static Map getConfiguration_JCE(MessageDigest algorithm) {
2425 Map result = null;
2426 result = new HashMap();
2427
2428 int digestLength = algorithm.getDigestLength();
2429 result.put("digestLength", new Integer(digestLength));
2430
2431 return result;
2432 }
2433
2434 /**
2435 * Define la configuración de un algoritmo criptográfico de autentificación
2436 * de huellas digitales JCE
2437 *
2438 * @param algorithm
2439 * Algoritmo criptográfico de autentificación de huellas
2440 * digitales JCE
2441 * @param configuration
2442 * Configuración
2443 * @see MessageDigest
2444 * @see #setConfiguration_JCEF(FingerPrint, Map)
2445 */
2446 public static void setConfiguration_JCE(MessageDigest algorithm,
2447 Map configuration) {
2448 }
2449
2450 /**
2451 * Obtiene la configuración de un algoritmo criptográfico de autentificación
2452 * mediante sellos digitales JCEF
2453 *
2454 * @param algorithm
2455 * Algoritmo criptográfico de autentificación mediante sellos
2456 * digitales JCEF
2457 * @return Configuración
2458 * @see DigitalSeal#getSymmetricKeyGenerator()
2459 * @see DigitalSeal#getSymmetricKeyTranslator()
2460 * @see DigitalSeal
2461 * @see #getConfiguration_JCEF(AuthenticationAlgorithm)
2462 * @see #getConfiguration_JCEF(DigitalPBESeal)
2463 * @see #getConfiguration_JCE(Mac)
2464 */
2465 public static Map getConfiguration_JCEF(DigitalSeal algorithm) {
2466 Map result = getConfiguration_JCEF((AuthenticationAlgorithm) algorithm);
2467 SymmetricKeyGenerator symmetricKeyGenerator = algorithm
2468 .getSymmetricKeyGenerator();
2469 SymmetricKeyTranslator symmetricKeyTranslator = algorithm
2470 .getSymmetricKeyTranslator();
2471 result.put("symmetricKeyGenerator", symmetricKeyGenerator);
2472 result.put("symmetricKeyTranslator", symmetricKeyTranslator);
2473
2474 return result;
2475 }
2476
2477 /**
2478 * Define la configuración de un algoritmo criptográfico de autentificación
2479 * mediante sellos digitales JCEF
2480 *
2481 * @param algorithm
2482 * Algoritmo criptográfico de autentificación mediante sellos
2483 * digitales JCEF
2484 * @param configuration
2485 * Configuración
2486 * @see #configure_JCEF(DigitalSeal, SymmetricKeyGenerator,
2487 * SymmetricKeyTranslator)
2488 * @see DigitalSeal
2489 * @see #setConfiguration_JCEF(AuthenticationAlgorithm, Map)
2490 * @see #setConfiguration_JCEF(DigitalPBESeal, Map)
2491 * @see #setConfiguration_JCE(Mac, Map)
2492 */
2493 public static void setConfiguration_JCEF(DigitalSeal algorithm,
2494 Map configuration) {
2495 setConfiguration_JCEF((AuthenticationAlgorithm) algorithm,
2496 configuration);
2497
2498 SymmetricKeyGenerator symmetricKeyGenerator = (SymmetricKeyGenerator) configuration
2499 .get("symmetricKeyGenerator");
2500 SymmetricKeyTranslator symmetricKeyTranslator = (SymmetricKeyTranslator) configuration
2501 .get("symmetricKeyTranslator");
2502 configure_JCEF(algorithm, symmetricKeyGenerator, symmetricKeyTranslator);
2503 }
2504
2505 /**
2506 * Configura de forma específica un algoritmo criptográfico de
2507 * autentificación mediante sellos digitales JCEF
2508 *
2509 * @param algorithm
2510 * Algoritmo criptográfico de autentificación mediante sellos
2511 * digitales JCEF
2512 * @param symmetricKeyGenerator
2513 * Parámetro de configuración para
2514 * {@link DigitalSeal#setSymmetricKeyGenerator(SymmetricKeyGenerator)}
2515 * @param symmetricKeyTranslator
2516 * Parámetro de configuración para
2517 * {@link DigitalSeal#setSymmetricKeyTranslator(SymmetricKeyTranslator)}
2518 * @see DigitalSeal#setSymmetricKeyGenerator(SymmetricKeyGenerator)
2519 * @see DigitalSeal#setSymmetricKeyTranslator(SymmetricKeyTranslator)
2520 */
2521 public static void configure_JCEF(DigitalSeal algorithm,
2522 SymmetricKeyGenerator symmetricKeyGenerator,
2523 SymmetricKeyTranslator symmetricKeyTranslator) {
2524 algorithm.setSymmetricKeyGenerator(symmetricKeyGenerator);
2525 algorithm.setSymmetricKeyTranslator(symmetricKeyTranslator);
2526 }
2527
2528 /**
2529 * Obtiene la configuración de un algoritmo criptográfico de autentificación
2530 * mediante sellos digitales JCE
2531 *
2532 * @param algorithm
2533 * Algoritmo criptográfico de autentificación mediante sellos
2534 * digitales JCE
2535 * @return Configuración
2536 * @see Mac#getMacLength()
2537 * @see Mac
2538 * @see #getConfiguration_JCEF(DigitalSeal)
2539 */
2540 public static Map getConfiguration_JCE(Mac algorithm) {
2541 Map result = null;
2542 result = new HashMap();
2543
2544 int macLength = algorithm.getMacLength();
2545 result.put("macLength", new Integer(macLength));
2546
2547 return result;
2548 }
2549
2550 /**
2551 * Define la configuración de un algoritmo criptográfico de autentificación
2552 * mediante sellos digitales JCE
2553 *
2554 * @param algorithm
2555 * Algoritmo criptográfico de autentificación mediante sellos
2556 * digitales JCE
2557 * @param configuration
2558 * Configuración
2559 * @see Mac
2560 * @see #setConfiguration_JCEF(DigitalSeal, Map)
2561 */
2562 public static void setConfiguration_JCE(Mac algorithm, Map configuration) {
2563 }
2564
2565 /**
2566 * Obtiene la configuración de un algoritmo criptográfico de autentificación
2567 * mediante sellos digitales basado en contraseñas JCEF
2568 *
2569 * @param algorithm
2570 * Algoritmo criptográfico de autentificación mediante sellos
2571 * digitales basado en contraseñas JCEF
2572 * @return Configuración
2573 * @see DigitalPBESeal
2574 * @see #getConfiguration_JCEF(DigitalSeal)
2575 */
2576 public static Map getConfiguration_JCEF(DigitalPBESeal algorithm) {
2577 Map result = getConfiguration_JCEF((DigitalSeal) algorithm);
2578
2579 return result;
2580 }
2581
2582 /**
2583 * Define la configuración de un algoritmo criptográfico de autentificación
2584 * mediante sellos digitales basado en contraseñas JCEF
2585 *
2586 * @param algorithm
2587 * Algoritmo criptográfico de autentificación mediante sellos
2588 * digitales basado en contraseñas JCEF
2589 * @param configuration
2590 * Configuración
2591 * @see #configure_JCEF(DigitalPBESeal)
2592 * @see #setConfiguration_JCEF(DigitalSeal, Map)
2593 */
2594 public static void setConfiguration_JCEF(DigitalPBESeal algorithm,
2595 Map configuration) {
2596 setConfiguration_JCEF((DigitalSeal) algorithm, configuration);
2597 configure_JCEF(algorithm);
2598 }
2599
2600 /**
2601 * Configura de forma específica un algoritmo criptográfico de
2602 * autentificación mediante sellos digitales basado en contraseñas JCEF
2603 *
2604 * @param algorithm
2605 * Algoritmo criptográfico de autentificación mediante sellos
2606 * digitales basado en contraseñas JCEF
2607 * @see #setConfiguration_JCEF(DigitalPBESeal, Map)
2608 */
2609 public static void configure_JCEF(DigitalPBESeal algorithm) {
2610 }
2611
2612 /**
2613 * Obtiene la configuración de un algoritmo criptográfico de autentificación
2614 * mediante firmas digitales JCEF
2615 *
2616 * @param algorithm
2617 * Algoritmo criptográfico de autentificación mediante firmas
2618 * digitales JCEF
2619 * @return Configuración
2620 * @see DigitalSignature#getAsymmetricKeyGenerator()
2621 * @see DigitalSignature#getAsymmetricKeyTranslator()
2622 * @see DigitalSignature
2623 * @see #getConfiguration_JCEF(AuthenticationAlgorithm)
2624 * @see #getConfiguration_JCE(Signature)
2625 */
2626 public static Map getConfiguration_JCEF(DigitalSignature algorithm) {
2627 Map result = getConfiguration_JCEF((AuthenticationAlgorithm) algorithm);
2628 AsymmetricKeyGenerator asymmetricKeyGenerator = algorithm
2629 .getAsymmetricKeyGenerator();
2630 AsymmetricKeyTranslator asymmetricKeyTranslator = algorithm
2631 .getAsymmetricKeyTranslator();
2632 result.put("asymmetricKeyGenerator", asymmetricKeyGenerator);
2633 result.put("asymmetricKeyTranslator", asymmetricKeyTranslator);
2634
2635 return result;
2636 }
2637
2638 /**
2639 * Define la configuración de un algoritmo criptográfico de autentificación
2640 * mediante firmas digitales JCEF
2641 *
2642 * @param algorithm
2643 * Algoritmo criptográfico de autentificación mediante firmas
2644 * digitales JCEF
2645 * @param configuration
2646 * Configuración
2647 * @see #configure_JCEF(DigitalSignature, AsymmetricKeyGenerator,
2648 * AsymmetricKeyTranslator)
2649 * @see DigitalSignature
2650 * @see #setConfiguration_JCEF(AuthenticationAlgorithm, Map)
2651 * @see #setConfiguration_JCE(Signature, Map)
2652 */
2653 public static void setConfiguration_JCEF(DigitalSignature algorithm,
2654 Map configuration) {
2655 setConfiguration_JCEF((AuthenticationAlgorithm) algorithm,
2656 configuration);
2657
2658 AsymmetricKeyGenerator asymmetricKeyGenerator = (AsymmetricKeyGenerator) configuration
2659 .get("asymmetricKeyGenerator");
2660 AsymmetricKeyTranslator asymmetricKeyTranslator = (AsymmetricKeyTranslator) configuration
2661 .get("asymmetricKeyTranslator");
2662 configure_JCEF(algorithm, asymmetricKeyGenerator,
2663 asymmetricKeyTranslator);
2664 }
2665
2666 /**
2667 * Configura de forma específica un algoritmo criptográfico de
2668 * autentificación mediante firmas digitales JCEF
2669 *
2670 * @param algorithm
2671 * Algoritmo criptográfico de autentificación mediante firmas
2672 * digitales JCEF
2673 * @param asymmetricKeyGenerator
2674 * Parámetro de configuración para
2675 * {@link DigitalSignature#setAsymmetricKeyGenerator(AsymmetricKeyGenerator)}
2676 * @param asymmetricKeyTranslator
2677 * Parámetro de configuración para
2678 * {@link DigitalSignature#setAsymmetricKeyTranslator(AsymmetricKeyTranslator)}
2679 * @see DigitalSignature#setAsymmetricKeyGenerator(AsymmetricKeyGenerator)
2680 * @see DigitalSignature#setAsymmetricKeyTranslator(AsymmetricKeyTranslator)
2681 * @see DigitalSignature
2682 * @see #setConfiguration_JCEF(DigitalSignature, Map)
2683 */
2684 public static void configure_JCEF(DigitalSignature algorithm,
2685 AsymmetricKeyGenerator asymmetricKeyGenerator,
2686 AsymmetricKeyTranslator asymmetricKeyTranslator) {
2687 algorithm.setAsymmetricKeyGenerator(asymmetricKeyGenerator);
2688 algorithm.setAsymmetricKeyTranslator(asymmetricKeyTranslator);
2689 }
2690
2691 /**
2692 * Obtiene la configuración de un algoritmo criptográfico de autentificación
2693 * mediante firmas digitales JCE
2694 *
2695 * @param algorithm
2696 * Algoritmo criptográfico de autentificación mediante firmas
2697 * digitales JCE
2698 * @return Configuración
2699 * @see Signature
2700 * @see #getConfiguration_JCEF(DigitalSignature)
2701 */
2702 public static Map getConfiguration_JCE(Signature algorithm) {
2703 Map result = null;
2704
2705 return result;
2706 }
2707
2708 /**
2709 * Define la configuración de un algoritmo criptográfico de autentificación
2710 * mediante firmas digitales JCE
2711 *
2712 * @param algorithm
2713 * Algoritmo criptográfico de autentificación mediante firmas
2714 * digitales JCE
2715 * @param configuration
2716 * Configuración
2717 * @see Signature
2718 * @see #setConfiguration_JCEF(DigitalSignature, Map)
2719 */
2720 public static void setConfiguration_JCE(Signature algorithm,
2721 Map configuration) {
2722 }
2723
2724 /**
2725 * Obtiene la configuración de un algoritmo criptográfico de protección JCEF
2726 *
2727 * @param algorithm
2728 * Algoritmo criptográfico de protección JCEF
2729 * @return Configuración
2730 * @see Protection
2731 * @see #getConfiguration_JCEF(CryptoAlgorithm)
2732 * @see #getConfiguration_JCEF(AsymmetricProtection)
2733 * @see #getConfiguration_JCEF(SymmetricProtection)
2734 * @see #getConfiguration_JCE(Cipher)
2735 */
2736 public static Map getConfiguration_JCEF(Protection algorithm) {
2737 Map result = getConfiguration_JCEF((CryptoAlgorithm) algorithm);
2738
2739 return result;
2740 }
2741
2742 /**
2743 * Define la configuración de un algoritmo criptográfico de protección JCEF
2744 *
2745 * @param algorithm
2746 * Algoritmo criptográfico de protección JCEF
2747 * @param configuration
2748 * Configuración
2749 * @see #configure_JCEF(Protection)
2750 * @see Protection
2751 * @see #setConfiguration_JCEF(CryptoAlgorithm, Map)
2752 * @see #setConfiguration_JCEF(AsymmetricProtection, Map)
2753 * @see #setConfiguration_JCEF(SymmetricProtection, Map)
2754 * @see #setConfiguration_JCE(Cipher, Map)
2755 */
2756 public static void setConfiguration_JCEF(Protection algorithm,
2757 Map configuration) {
2758 setConfiguration_JCEF((CryptoAlgorithm) algorithm, configuration);
2759 configure_JCEF(algorithm);
2760 }
2761
2762 /**
2763 * Configura de forma específica un algoritmo criptográfico de protección
2764 * JCEF
2765 *
2766 * @param algorithm
2767 * Algoritmo criptográfico de protección JCEF
2768 * @see #setConfiguration_JCEF(Protection, Map)
2769 */
2770 public static void configure_JCEF(Protection algorithm) {
2771 }
2772
2773 /**
2774 * Obtiene la configuración de un algoritmo criptográfico de protección JCE
2775 *
2776 * @param algorithm
2777 * Algoritmo criptográfico de protección JCE
2778 * @return Configuración
2779 * @see Cipher
2780 * @see Cipher#getBlockSize()
2781 * @see #getConfiguration_JCEF(Protection)
2782 */
2783 public static Map getConfiguration_JCE(Cipher algorithm) {
2784 Map result = null;
2785 result = new HashMap();
2786
2787 int blockSize = algorithm.getBlockSize();
2788 result.put("blockSize", new Integer(blockSize));
2789
2790 return result;
2791 }
2792
2793 /**
2794 * Define la configuración de un algoritmo criptográfico de protección JCE
2795 *
2796 * @param algorithm
2797 * Algoritmo criptográfico de protección JCE
2798 * @param configuration
2799 * Configuración
2800 * @see Cipher
2801 * @see #setConfiguration_JCEF(Protection, Map)
2802 */
2803 public static void setConfiguration_JCE(Cipher algorithm, Map configuration) {
2804 }
2805
2806 /**
2807 * Obtiene la configuración de un algoritmo criptográfico de protección
2808 * asimétrica JCEF
2809 *
2810 * @param algorithm
2811 * Algoritmo criptográfico de protección asimétrica JCEF
2812 * @return Configuración
2813 * @see AsymmetricProtection#getAsymmetricKeyGenerator()
2814 * @see AsymmetricProtection#getAsymmetricKeyTranslator()
2815 * @see AsymmetricProtection
2816 * @see #getConfiguration_JCEF(Protection)
2817 */
2818 public static Map getConfiguration_JCEF(AsymmetricProtection algorithm) {
2819 Map result = getConfiguration_JCEF((Protection) algorithm);
2820 AsymmetricKeyGenerator asymmetricKeyGenerator = algorithm
2821 .getAsymmetricKeyGenerator();
2822 AsymmetricKeyTranslator asymmetricKeyTranslator = algorithm
2823 .getAsymmetricKeyTranslator();
2824 result.put("asymmetricKeyGenerator", asymmetricKeyGenerator);
2825 result.put("asymmetricKeyTranslator", asymmetricKeyTranslator);
2826
2827 return result;
2828 }
2829
2830 /**
2831 * Define la configuración de un algoritmo criptográfico de protección
2832 * asimétrica JCEF
2833 *
2834 * @param algorithm
2835 * Algoritmo criptográfico de protección asimétrica JCEF
2836 * @param configuration
2837 * Configuración
2838 * @see #configure_JCEF(AsymmetricProtection, AsymmetricKeyGenerator,
2839 * AsymmetricKeyTranslator)
2840 * @see AsymmetricProtection
2841 * @see #setConfiguration_JCEF(Protection, Map)
2842 */
2843 public static void setConfiguration_JCEF(AsymmetricProtection algorithm,
2844 Map configuration) {
2845 setConfiguration_JCEF((Protection) algorithm, configuration);
2846
2847 AsymmetricKeyGenerator asymmetricKeyGenerator = (AsymmetricKeyGenerator) configuration
2848 .get("asymmetricKeyGenerator");
2849 AsymmetricKeyTranslator asymmetricKeyTranslator = (AsymmetricKeyTranslator) configuration
2850 .get("asymmetricKeyTranslator");
2851 configure_JCEF(algorithm, asymmetricKeyGenerator,
2852 asymmetricKeyTranslator);
2853 }
2854
2855 /**
2856 * Configura de forma específica un algoritmo criptográfico de protección
2857 * asimétrica JCEF
2858 *
2859 * @param algorithm
2860 * Algoritmo criptográfico de protección asimétrica JCEF
2861 * @param asymmetricKeyGenerator
2862 * Parámetro de configuración para {@link }
2863 * @param asymmetricKeyTranslator
2864 * Parámetro de configuración para {@link }
2865 * @see AsymmetricProtection#setAsymmetricKeyGenerator(AsymmetricKeyGenerator)
2866 * @see AsymmetricProtection#setAsymmetricKeyTranslator(AsymmetricKeyTranslator)
2867 * @see AsymmetricProtection
2868 * @see #setConfiguration_JCEF(AsymmetricProtection, Map)
2869 */
2870 public static void configure_JCEF(AsymmetricProtection algorithm,
2871 AsymmetricKeyGenerator asymmetricKeyGenerator,
2872 AsymmetricKeyTranslator asymmetricKeyTranslator) {
2873 algorithm.setAsymmetricKeyGenerator(asymmetricKeyGenerator);
2874 algorithm.setAsymmetricKeyTranslator(asymmetricKeyTranslator);
2875 }
2876
2877 /**
2878 * Obtiene la configuración de un algoritmo criptográfico de protección
2879 * simétrica JCEF
2880 *
2881 * @param algorithm
2882 * Algoritmo criptográfico de protección simétrica JCEF
2883 * @return Configuración
2884 * @see SymmetricProtection#getSymmetricKeyGenerator()
2885 * @see SymmetricProtection#getSymmetricKeyTranslator()
2886 * @see SymmetricProtection
2887 * @see #getConfiguration_JCEF(Protection)
2888 * @see #getConfiguration_JCEF(BlockSymmetricProtection)
2889 * @see #getConfiguration_JCEF(StreamSymmetricProtection)
2890 * @see #getConfiguration_JCEF(PBEProtection)
2891 */
2892 public static Map getConfiguration_JCEF(SymmetricProtection algorithm) {
2893 Map result = getConfiguration_JCEF((Protection) algorithm);
2894 SymmetricKeyTranslator symmetricKeyTranslator = algorithm
2895 .getSymmetricKeyTranslator();
2896 SymmetricKeyGenerator symmetricKeyGenerator = algorithm
2897 .getSymmetricKeyGenerator();
2898 result.put("symmetricKeyTranslator", symmetricKeyTranslator);
2899 result.put("symmetricKeyGenerator", symmetricKeyGenerator);
2900
2901 return result;
2902 }
2903
2904 /**
2905 * Define la configuración de un algoritmo criptográfico de protección
2906 * simétrica JCEF
2907 *
2908 * @param algorithm
2909 * Algoritmo criptográfico de protección simétrica JCEF
2910 * @param configuration
2911 * Configuración
2912 * @see #configure_JCEF(SymmetricProtection, SymmetricKeyGenerator,
2913 * SymmetricKeyTranslator)
2914 * @see SymmetricProtection
2915 * @see #setConfiguration_JCEF(Protection, Map)
2916 * @see #setConfiguration_JCEF(BlockSymmetricProtection, Map)
2917 * @see #setConfiguration_JCEF(StreamSymmetricProtection, Map)
2918 * @see #setConfiguration_JCEF(PBEProtection, Map)
2919 */
2920 public static void setConfiguration_JCEF(SymmetricProtection algorithm,
2921 Map configuration) {
2922 setConfiguration_JCEF((Protection) algorithm, configuration);
2923
2924 SymmetricKeyGenerator symmetricKeyGenerator = (SymmetricKeyGenerator) configuration
2925 .get("symmetricKeyGenerator");
2926 SymmetricKeyTranslator symmetricKeyTranslator = (SymmetricKeyTranslator) configuration
2927 .get("symmetricKeyTranslator");
2928 configure_JCEF(algorithm, symmetricKeyGenerator, symmetricKeyTranslator);
2929 }
2930
2931 /**
2932 * Configura de forma específica un algoritmo criptográfico de protección
2933 * simétrica JCEF
2934 *
2935 * @param algorithm
2936 * Algoritmo criptográfico de protección simétrica JCEF
2937 * @param symmetricKeyGenerator
2938 * Parámetro de configuración para
2939 * {@link SymmetricProtection#setSymmetricKeyGenerator(SymmetricKeyGenerator)}
2940 * @param symmetricKeyTranslator
2941 * Parámetro de configuración para
2942 * {@link SymmetricProtection#setSymmetricKeyTranslator(SymmetricKeyTranslator)}
2943 * @see SymmetricProtection#setSymmetricKeyGenerator(SymmetricKeyGenerator)
2944 * @see SymmetricProtection#setSymmetricKeyTranslator(SymmetricKeyTranslator)
2945 * @see SymmetricProtection
2946 * @see #setConfiguration_JCEF(SymmetricProtection, Map)
2947 */
2948 public static void configure_JCEF(SymmetricProtection algorithm,
2949 SymmetricKeyGenerator symmetricKeyGenerator,
2950 SymmetricKeyTranslator symmetricKeyTranslator) {
2951 algorithm.setSymmetricKeyGenerator(symmetricKeyGenerator);
2952 algorithm.setSymmetricKeyTranslator(symmetricKeyTranslator);
2953 }
2954
2955 /**
2956 * Obtiene la configuración de un algoritmo criptográfico de protección
2957 * simétrica de bloques JCEF
2958 *
2959 * @param algorithm
2960 * Algoritmo criptográfico de protección simétrica de bloques
2961 * JCEF
2962 * @return Configuración
2963 * @see BlockSymmetricProtection#getBlockSize()
2964 * @see BlockSymmetricProtection
2965 * @see #getConfiguration_JCEF(SymmetricProtection)
2966 */
2967 public static Map getConfiguration_JCEF(BlockSymmetricProtection algorithm) {
2968 Map result = getConfiguration_JCEF((SymmetricProtection) algorithm);
2969 int blockSize = algorithm.getBlockSize();
2970 result.put("blockSize", new Integer(blockSize));
2971
2972 return result;
2973 }
2974
2975 /**
2976 * Define la configuración de un algoritmo criptográfico de protección
2977 * simétrica de bloques JCEF
2978 *
2979 * @param algorithm
2980 * Algoritmo criptográfico de protección simétrica de bloques
2981 * JCEF
2982 * @param configuration
2983 * Configuración
2984 * @see #configure_JCEF(BlockSymmetricProtection, int)
2985 * @see BlockSymmetricProtection
2986 * @see #setConfiguration_JCEF(SymmetricProtection, Map)
2987 */
2988 public static void setConfiguration_JCEF(
2989 BlockSymmetricProtection algorithm, Map configuration) {
2990 setConfiguration_JCEF((SymmetricProtection) algorithm, configuration);
2991
2992 int blockSize = ((Integer) configuration.get("blockSize")).intValue();
2993 configure_JCEF(algorithm, blockSize);
2994 }
2995
2996 /**
2997 * Configura de forma específica un algoritmo criptográfico de protección
2998 * simétrica de bloques JCEF
2999 *
3000 * @param algorithm
3001 * Algoritmo criptográfico de protección simétrica de bloques
3002 * JCEF
3003 * @param blockSize
3004 * Parámetro de configuración para
3005 * {@link BlockSymmetricProtection#setBlockSize(int)}
3006 * @see BlockSymmetricProtection#setBlockSize(int)
3007 * @see BlockSymmetricProtection
3008 * @see #setConfiguration_JCEF(BlockSymmetricProtection, Map)
3009 */
3010 public static void configure_JCEF(BlockSymmetricProtection algorithm,
3011 int blockSize) {
3012 algorithm.setBlockSize(blockSize);
3013 }
3014
3015 /**
3016 * Obtiene la configuración de un algoritmo criptográfico de protección
3017 * simétrica de flujo JCEF
3018 *
3019 * @param algorithm
3020 * Algoritmo criptográfico de protección simétrica de flujo JCEF
3021 * @return Configuración
3022 * @see StreamSymmetricProtection
3023 * @see #getConfiguration_JCEF(SymmetricProtection)
3024 */
3025 public static Map getConfiguration_JCEF(StreamSymmetricProtection algorithm) {
3026 Map result = getConfiguration_JCEF((SymmetricProtection) algorithm);
3027
3028 return result;
3029 }
3030
3031 /**
3032 * Define la configuración de un algoritmo criptográfico de protección
3033 * simétrica de flujo JCEF
3034 *
3035 * @param algorithm
3036 * Algoritmo criptográfico de protección simétrica de flujo JCEF
3037 * @param configuration
3038 * Configuración
3039 * @see #configure_JCEF(StreamSymmetricProtection)
3040 * @see StreamSymmetricProtection
3041 * @see #setConfiguration_JCEF(SymmetricProtection, Map)
3042 */
3043 public void setConfiguration_JCEF(StreamSymmetricProtection algorithm,
3044 Map configuration) {
3045 setConfiguration_JCEF((SymmetricProtection) algorithm, configuration);
3046 configure_JCEF(algorithm);
3047 }
3048
3049 /**
3050 * Configura de forma específica un algoritmo criptográfico de protección
3051 * simétrica de flujo JCEF
3052 *
3053 * @param algorithm
3054 * Algoritmo criptográfico de protección simétrica de flujo JCEF
3055 * @see StreamSymmetricProtection
3056 * @see #setConfiguration_JCEF(StreamSymmetricProtection, Map)
3057 */
3058 public static void configure_JCEF(StreamSymmetricProtection algorithm) {
3059 }
3060
3061 /**
3062 * Obtiene la configuración de un algoritmo criptográfico de protección
3063 * simétrica basado en contraseñas JCEF
3064 *
3065 * @param algorithm
3066 * Algoritmo criptográfico de protección simétrica basado en
3067 * contraseñas JCEF
3068 * @return Configuración
3069 * @see PBEProtection
3070 * @see #getConfiguration_JCEF(SymmetricProtection)
3071 */
3072 public static Map getConfiguration_JCEF(PBEProtection algorithm) {
3073 Map result = getConfiguration_JCEF((SymmetricProtection) algorithm);
3074
3075 return result;
3076 }
3077
3078 /**
3079 * Configura de forma específica un algoritmo criptográfico de protección
3080 * simétrica basado en contraseñas JCEF
3081 *
3082 * @param algorithm
3083 * Algoritmo criptográfico de protección simétrica basado en
3084 * contraseñas JCEF
3085 * @param configuration
3086 * Configuración
3087 * @see #configure_JCEF(PBEProtection)
3088 * @see PBEProtection
3089 * @see #setConfiguration_JCEF(SymmetricProtection, Map)
3090 */
3091 public static void setConfiguration_JCEF(PBEProtection algorithm,
3092 Map configuration) {
3093 setConfiguration_JCEF((SymmetricProtection) algorithm, configuration);
3094 configure_JCEF(algorithm);
3095 }
3096
3097 /**
3098 * Configura de forma específica un algoritmo criptográfico de protección
3099 * simétrica basado en contraseñas JCEF
3100 *
3101 * @param algorithm
3102 * Algoritmo criptográfico de protección simétrica basado en
3103 * contraseñas JCEF
3104 * @see PBEProtection
3105 * @see #setConfiguration_JCEF(PBEProtection, Map)
3106 */
3107 public static void configure_JCEF(PBEProtection algorithm) {
3108 }
3109 }
3110
3111 /**
3112 * JCEF permite realizar adaptaciones de algoritmos ya existentes (JCE y no JCE)
3113 * relacionados con la criptografía y también posibilita implementar nuevos
3114 * algoritmos
3115 * <UL>
3116 * Existen un total de 5 implementaciones JCEF:
3117 * <LI>Facade: Genera los parámetros de inicialización automáticamente cuando
3118 * son necesarios, es decir, es innecesario especificar dichos parámetros de
3119 * inicialización</LI>
3120 * <LI>JCEAdapter: Permite reutilizar los algoritmos JCE con una especificación
3121 * JCEF, es decir, adapta la interfaz JCE a la interfaz JCEF</LI>
3122 * <LI>JCESpiAdapter: Adapta la interfaz de definición de JCE a la interfaz
3123 * JCEF, es decir, permite utilizar algoritmos JCEF como si fueran algoritmos
3124 * JCE</LI>
3125 * <LI>NewImpl: Esta implementación está pensada para realizar la
3126 * implementación de nuevos algoritmos no implementados, utilizando para ello la
3127 * especificación JCEF</LI>
3128 * <LI>Adapter: Esta implementación JCEF incluye la funcionalidad de las
3129 * implementaciones JCESpiAdapter, JCEAdapter y Facade. Es decir, permite
3130 * implementar nuevos algoritmos JCEF que cumplan con la especificación JCE, ya
3131 * sean adaptaciones de algoritmos JCE existentes o nuevas implementaciones de
3132 * algoritmos</LI>
3133 * </UL>
3134 * <UL>
3135 * Para añadir nuevos algoritmos JCEF basta con heredar de algunas de las clases
3136 * de una o varias implementaciones y también es necesaria configurar dicho
3137 * algoritmo tal y como se muestra en {@link ConfiguratingAlgorithms}. Para
3138 * ello, véanse ejemplos tales como:
3139 * <LI>Para la implementación Facade, tenemos:
3140 * <UL>
3141 * <LI>Objeto JCEF: {@link JCEFObject_FacadeImplDefaultTestCase}</LI>
3142 * <LI>Proveedor JCEF: {@link JCEFProvider_FacadeImplDefaultTestCase}</LI>
3143 * <LI>Algoritmo: {@link Algorithm_FacadeImplDefaultTestCase}</LI>
3144 * <LI>Algoritmo-Traductor: {@link Translator_FacadeImplDefaultTestCase}</LI>
3145 * <LI>Algoritmo-Traductor de claves:
3146 * {@link KeyTranslator_FacadeImplDefaultTestCase}</LI>
3147 * <LI>Algoritmo-Traductor de claves asimétricas:
3148 * {@link AsymmetricKeyTranslator_FacadeImplDefaultTestCase}</LI>
3149 * <LI>Algoritmo-Traductor de claves simétricas:
3150 * {@link SymmetricKeyTranslator_FacadeImplDefaultTestCase}</LI>
3151 * <LI>Algoritmo-Traductor de parámetros:
3152 * {@link ParameterTranslator_FacadeImplDefaultTestCase}</LI>
3153 * <LI>Algoritmo-Generador: {@link Generator_FacadeImplDefaultTestCase}</LI>
3154 * <LI>Algoritmo-Generador de claves:
3155 * {@link KeyGenerator_FacadeImplDefaultTestCase}</LI>
3156 * <LI>Algoritmo-Generador de claves asimétricas:
3157 * {@link AsymmetricKeyGenerator_FacadeImplDefaultTestCase}</LI>
3158 * <LI>Algoritmo-Generador de claves simétricas:
3159 * {@link SymmetricKeyGenerator_FacadeImplDefaultTestCase}</LI>
3160 * <LI>Algoritmo-Generador de parámetros:
3161 * {@link ParameterGenerator_FacadeImplDefaultTestCase}</LI>
3162 * <LI>Algoritmo-Generador de datos aleatorios:
3163 * {@link SecureRandomGenerator_FacadeImplDefaultTestCase}</LI>
3164 * <LI>Algoritmo criptográfico:
3165 * {@link CryptoAlgorithm_FacadeImplDefaultTestCase}</LI>
3166 * <LI>Algoritmo criptográfico de autentificación:
3167 * {@link AuthenticationAlgorithm_FacadeImplDefaultTestCase}</LI>
3168 * <LI>Algoritmo criptográfico de autentificación mediante huellas digitales:
3169 * {@link FingerPrint_FacadeImplDefaultTestCase}</LI>
3170 * <LI>Algoritmo criptográfico de autentificación mediante sellos digitales:
3171 * {@link DigitalSeal_FacadeImplDefaultTestCase}</LI>
3172 * <LI>Algoritmo criptográfico de autentificación mediante sellos digitales
3173 * basado en contraseña: {@link DigitalPBESeal_FacadeImplDefaultTestCase}</LI>
3174 * <LI>Algoritmo criptográfico de autentificación mediante firmas digitales:
3175 * {@link DigitalSignature_FacadeImplDefaultTestCase}</LI>
3176 * <LI>Algoritmo criptográfico de protección:
3177 * {@link Protection_FacadeImplDefaultTestCase}</LI>
3178 * <LI>Algoritmo criptográfico de protección asimétrica:
3179 * {@link AsymmetricProtection_FacadeImplDefaultTestCase}</LI>
3180 * <LI>Algoritmo criptográfico de protección simétrica:
3181 * {@link SymmetricProtection_FacadeImplDefaultTestCase}</LI>
3182 * <LI>Algoritmo criptográfico de protección simétrica de bloques:
3183 * {@link BlockSymmetricProtection_FacadeImplDefaultTestCase}</LI>
3184 * <LI>Algoritmo criptográfico de protección simétrica de flujo:
3185 * {@link StreamSymmetricProtection_FacadeImplDefaultTestCase}</LI>
3186 * <LI>Algoritmo criptográfico de protección basada en contraseña:
3187 * {@link PBEProtection_FacadeImplDefaultTestCase}</LI>
3188 * </UL>
3189 * </LI>
3190 * <LI>Para la implementación JCEAdapter, tenemos:
3191 * <UL>
3192 * <LI>Objeto JCEF: {@link JCEFObject_JCEAdapterDefaultTestCase}</LI>
3193 * <LI>Proveedor JCEF: {@link JCEFProvider_JCEAdapterDefaultTestCase}</LI>
3194 * <LI>Algoritmo: {@link Algorithm_JCEAdapterDefaultTestCase}</LI>
3195 * <LI>Algoritmo-Traductor: {@link Translator_JCEAdapterDefaultTestCase}</LI>
3196 * <LI>Algoritmo-Traductor de claves:
3197 * {@link KeyTranslator_JCEAdapterDefaultTestCase}</LI>
3198 * <LI>Algoritmo-Traductor de claves asimétricas:
3199 * {@link AsymmetricKeyTranslator_JCEAdapterDefaultTestCase}</LI>
3200 * <LI>Algoritmo-Traductor de claves simétricas:
3201 * {@link SymmetricKeyTranslator_JCEAdapterDefaultTestCase}</LI>
3202 * <LI>Algoritmo-Traductor de parámetros:
3203 * {@link ParameterTranslator_JCEAdapterDefaultTestCase}</LI>
3204 * <LI>Algoritmo-Generador: {@link Generator_JCEAdapterDefaultTestCase}</LI>
3205 * <LI>Algoritmo-Generador de claves:
3206 * {@link KeyGenerator_JCEAdapterDefaultTestCase}</LI>
3207 * <LI>Algoritmo-Generador de claves asimétricas:
3208 * {@link AsymmetricKeyGenerator_JCEAdapterDefaultTestCase}</LI>
3209 * <LI>Algoritmo-Generador de claves simétricas:
3210 * {@link SymmetricKeyGenerator_JCEAdapterDefaultTestCase}</LI>
3211 * <LI>Algoritmo-Generador de parámetros:
3212 * {@link ParameterGenerator_JCEAdapterDefaultTestCase}</LI>
3213 * <LI>Algoritmo-Generador de datos aleatorios:
3214 * {@link SecureRandomGenerator_JCEAdapterDefaultTestCase}</LI>
3215 * <LI>Algoritmo criptográfico:
3216 * {@link CryptoAlgorithm_JCEAdapterDefaultTestCase}</LI>
3217 * <LI>Algoritmo criptográfico de autentificación:
3218 * {@link AuthenticationAlgorithm_JCEAdapterDefaultTestCase}</LI>
3219 * <LI>Algoritmo criptográfico de autentificación mediante huellas digitales:
3220 * {@link FingerPrint_JCEAdapterDefaultTestCase}</LI>
3221 * <LI>Algoritmo criptográfico de autentificación mediante sellos digitales:
3222 * {@link DigitalSeal_JCEAdapterDefaultTestCase}</LI>
3223 * <LI>Algoritmo criptográfico de autentificación mediante sellos digitales
3224 * basado en contraseña: {@link DigitalPBESeal_JCEAdapterDefaultTestCase}</LI>
3225 * <LI>Algoritmo criptográfico de autentificación mediante firmas digitales:
3226 * {@link DigitalSignature_JCEAdapterDefaultTestCase}</LI>
3227 * <LI>Algoritmo criptográfico de protección:
3228 * {@link Protection_JCEAdapterDefaultTestCase}</LI>
3229 * <LI>Algoritmo criptográfico de protección asimétrica:
3230 * {@link AsymmetricProtection_JCEAdapterDefaultTestCase}</LI>
3231 * <LI>Algoritmo criptográfico de protección simétrica:
3232 * {@link SymmetricProtection_JCEAdapterDefaultTestCase}</LI>
3233 * <LI>Algoritmo criptográfico de protección simétrica de bloques:
3234 * {@link BlockSymmetricProtection_JCEAdapterDefaultTestCase}</LI>
3235 * <LI>Algoritmo criptográfico de protección simétrica de flujo:
3236 * {@link StreamSymmetricProtection_JCEAdapterDefaultTestCase}</LI>
3237 * <LI>Algoritmo criptográfico de protección basada en contraseña:
3238 * {@link PBEProtection_JCEAdapterDefaultTestCase}</LI>
3239 * </UL>
3240 * </LI>
3241 * <LI>Para la implementación JCESpiAdapter, tenemos:
3242 * <UL>
3243 * <LI>Objeto JCEF: {@link JCEFObject_JCESpiAdapterDefaultTestCase}</LI>
3244 * <LI>Proveedor JCEF: {@link JCEFProvider_JCESpiAdapterDefaultTestCase}</LI>
3245 * <LI>Algoritmo: {@link Algorithm_JCESpiAdapterDefaultTestCase}</LI>
3246 * <LI>Algoritmo-Traductor: {@link Translator_JCESpiAdapterDefaultTestCase}</LI>
3247 * <LI>Algoritmo-Traductor de claves:
3248 * {@link KeyTranslator_JCESpiAdapterDefaultTestCase}</LI>
3249 * <LI>Algoritmo-Traductor de claves asimétricas:
3250 * {@link AsymmetricKeyTranslator_JCESpiAdapterDefaultTestCase}</LI>
3251 * <LI>Algoritmo-Traductor de claves simétricas:
3252 * {@link SymmetricKeyTranslator_JCESpiAdapterDefaultTestCase}</LI>
3253 * <LI>Algoritmo-Traductor de parámetros:
3254 * {@link ParameterTranslator_JCESpiAdapterDefaultTestCase}</LI>
3255 * <LI>Algoritmo-Generador: {@link Generator_JCESpiAdapterDefaultTestCase}</LI>
3256 * <LI>Algoritmo-Generador de claves:
3257 * {@link KeyGenerator_JCESpiAdapterDefaultTestCase}</LI>
3258 * <LI>Algoritmo-Generador de claves asimétricas:
3259 * {@link AsymmetricKeyGenerator_JCESpiAdapterDefaultTestCase}</LI>
3260 * <LI>Algoritmo-Generador de claves simétricas:
3261 * {@link SymmetricKeyGenerator_JCESpiAdapterDefaultTestCase}</LI>
3262 * <LI>Algoritmo-Generador de parámetros:
3263 * {@link ParameterGenerator_JCESpiAdapterDefaultTestCase}</LI>
3264 * <LI>Algoritmo-Generador de datos aleatorios:
3265 * {@link SecureRandomGenerator_JCESpiAdapterDefaultTestCase}</LI>
3266 * <LI>Algoritmo criptográfico:
3267 * {@link CryptoAlgorithm_JCESpiAdapterDefaultTestCase}</LI>
3268 * <LI>Algoritmo criptográfico de autentificación:
3269 * {@link AuthenticationAlgorithm_JCESpiAdapterDefaultTestCase}</LI>
3270 * <LI>Algoritmo criptográfico de autentificación mediante huellas digitales:
3271 * {@link FingerPrint_JCESpiAdapterDefaultTestCase}</LI>
3272 * <LI>Algoritmo criptográfico de autentificación mediante sellos digitales:
3273 * {@link DigitalSeal_JCESpiAdapterDefaultTestCase}</LI>
3274 * <LI>Algoritmo criptográfico de autentificación mediante sellos digitales
3275 * basado en contraseña: {@link DigitalPBESeal_JCESpiAdapterDefaultTestCase}</LI>
3276 * <LI>Algoritmo criptográfico de autentificación mediante firmas digitales:
3277 * {@link DigitalSignature_JCESpiAdapterDefaultTestCase}</LI>
3278 * <LI>Algoritmo criptográfico de protección:
3279 * {@link Protection_JCESpiAdapterDefaultTestCase}</LI>
3280 * <LI>Algoritmo criptográfico de protección asimétrica:
3281 * {@link AsymmetricProtection_JCESpiAdapterDefaultTestCase}</LI>
3282 * <LI>Algoritmo criptográfico de protección simétrica:
3283 * {@link SymmetricProtection_JCESpiAdapterDefaultTestCase}</LI>
3284 * <LI>Algoritmo criptográfico de protección simétrica de bloques:
3285 * {@link BlockSymmetricProtection_JCESpiAdapterDefaultTestCase}</LI>
3286 * <LI>Algoritmo criptográfico de protección simétrica de flujo:
3287 * {@link StreamSymmetricProtection_JCESpiAdapterDefaultTestCase}</LI>
3288 * <LI>Algoritmo criptográfico de protección basada en contraseña:
3289 * {@link PBEProtection_JCESpiAdapterDefaultTestCase}</LI>
3290 * </UL>
3291 * </LI>
3292 * <LI>Para la implementación "NewImpl", tenemos:
3293 * <UL>
3294 * <LI>Objeto JCEF: {@link JCEFObject_NewImplDefaultTestCase}</LI>
3295 * <LI>Proveedor JCEF: {@link JCEFProvider_NewImplDefaultTestCase}</LI>
3296 * <LI>Algoritmo: {@link Algorithm_NewImplDefaultTestCase}</LI>
3297 * <LI>Algoritmo-Traductor: {@link Translator_NewImplDefaultTestCase}</LI>
3298 * <LI>Algoritmo-Traductor de claves:
3299 * {@link KeyTranslator_NewImplDefaultTestCase}</LI>
3300 * <LI>Algoritmo-Traductor de claves asimétricas:
3301 * {@link AsymmetricKeyTranslator_NewImplDefaultTestCase}</LI>
3302 * <LI>Algoritmo-Traductor de claves simétricas:
3303 * {@link SymmetricKeyTranslator_NewImplDefaultTestCase}</LI>
3304 * <LI>Algoritmo-Traductor de parámetros:
3305 * {@link ParameterTranslator_NewImplDefaultTestCase}</LI>
3306 * <LI>Algoritmo-Generador: {@link Generator_NewImplDefaultTestCase}</LI>
3307 * <LI>Algoritmo-Generador de claves:
3308 * {@link KeyGenerator_NewImplDefaultTestCase}</LI>
3309 * <LI>Algoritmo-Generador de claves asimétricas:
3310 * {@link AsymmetricKeyGenerator_NewImplDefaultTestCase}</LI>
3311 * <LI>Algoritmo-Generador de claves simétricas:
3312 * {@link SymmetricKeyGenerator_NewImplDefaultTestCase}</LI>
3313 * <LI>Algoritmo-Generador de parámetros:
3314 * {@link ParameterGenerator_NewImplDefaultTestCase}</LI>
3315 * <LI>Algoritmo-Generador de datos aleatorios:
3316 * {@link SecureRandomGenerator_NewImplDefaultTestCase}</LI>
3317 * <LI>Algoritmo criptográfico: {@link CryptoAlgorithm_NewImplDefaultTestCase}</LI>
3318 * <LI>Algoritmo criptográfico de autentificación:
3319 * {@link AuthenticationAlgorithm_NewImplDefaultTestCase}</LI>
3320 * <LI>Algoritmo criptográfico de autentificación mediante huellas digitales:
3321 * {@link FingerPrint_NewImplDefaultTestCase}</LI>
3322 * <LI>Algoritmo criptográfico de autentificación mediante sellos digitales:
3323 * {@link DigitalSeal_NewImplDefaultTestCase}</LI>
3324 * <LI>Algoritmo criptográfico de autentificación mediante sellos digitales
3325 * basado en contraseña: {@link DigitalPBESeal_NewImplDefaultTestCase}</LI>
3326 * <LI>Algoritmo criptográfico de autentificación mediante firmas digitales:
3327 * {@link DigitalSignature_NewImplDefaultTestCase}</LI>
3328 * <LI>Algoritmo criptográfico de protección:
3329 * {@link Protection_NewImplDefaultTestCase}</LI>
3330 * <LI>Algoritmo criptográfico de protección asimétrica:
3331 * {@link AsymmetricProtection_NewImplDefaultTestCase}</LI>
3332 * <LI>Algoritmo criptográfico de protección simétrica:
3333 * {@link SymmetricProtection_NewImplDefaultTestCase}</LI>
3334 * <LI>Algoritmo criptográfico de protección simétrica de bloques:
3335 * {@link BlockSymmetricProtection_NewImplDefaultTestCase}</LI>
3336 * <LI>Algoritmo criptográfico de protección simétrica de flujo:
3337 * {@link StreamSymmetricProtection_NewImplDefaultTestCase}</LI>
3338 * <LI>Algoritmo criptográfico de protección basada en contraseña:
3339 * {@link PBEProtection_NewImplDefaultTestCase}</LI>
3340 * </UL>
3341 * </LI>
3342 * <LI>Para la implementación "Adapter", tenemos:
3343 * <UL>
3344 * <LI>Proveedor JCEF: {@link SUNJCEFProvider}, {@link JacksumJCEFProvider},
3345 * {@link LogiCryptoJCEFProvider}, {@link MindbrightJCEFProvider}</LI>
3346 * <LI>Algoritmo-Traductor de claves asimétricas:
3347 * {@link DSAAsymmetricKeyTranslator_SUN},
3348 * {@link RSAAsymmetricKeyTranslator_LogiCrypto},
3349 * {@link RSAAsymmetricKeyTranslator_Mindbright}</LI>
3350 * <LI>Algoritmo-Traductor de claves simétricas:
3351 * {@link AESSymmetricKeyTranslator_SunJCE},
3352 * {@link TripleDESSymmetricKeyTranslator_LogiCrypto},
3353 * {@link RC2SymmetricKeyTranslator_Mindbright}</LI>
3354 * <LI>Algoritmo-Traductor de parámetros: {@link DSAParameterTranslator_SUN},
3355 * {@link RSAOAEPParameterTranslator_SunJCE}</LI>
3356 * <LI>Algoritmo-Generador de claves asimétricas:
3357 * {@link DSAAsymmetricKeyGenerator_SUN},
3358 * {@link RSAAsymmetricKeyGenerator_LogiCrypto},
3359 * {@link DSAAsymmetricKeyGenerator_Mindbright}</LI>
3360 * <LI>Algoritmo-Generador de claves simétricas:
3361 * {@link HmacMD5SymmetricKeyGenerator_SunJCE},
3362 * {@link DESSymmetricKeyGenerator_LogiCrypto},
3363 * {@link TripleDESSymmetricKeyGenerator_Mindbright}</LI>
3364 * <LI>Algoritmo-Generador de parámetros: {@link DSAParameterGenerator_SUN},
3365 * {@link RSAOAEPParameterGenerator_SunJCE}, </LI>
3366 * <LI>Algoritmo-Generador de datos aleatorios:
3367 * {@link BlumBlumShubSecureRandomGenerator_Mindbright}</LI>
3368 * <LI>Algoritmo criptográfico de autentificación mediante huellas digitales:
3369 * {@link MD5FingerPrint_SUN}, {@link WhirlpoolFingerPrint_Jacksum},
3370 * {@link SHA1FingerPrint_LogiCrypto}, {@link RIPEMD160FingerPrint_Mindbright}</LI>
3371 * <LI>Algoritmo criptográfico de autentificación mediante sellos digitales:
3372 * {@link HmacMD5DigitalSeal_SunJCE}, {@link HmacSHA1DigitalSeal_Mindbright}</LI>
3373 * <LI>Algoritmo criptográfico de autentificación mediante sellos digitales
3374 * basado en contraseña: {@link PBEHmacSHA1DigitalPBESeal_SunJCE}</LI>
3375 * <LI>Algoritmo criptográfico de autentificación mediante firmas digitales:
3376 * {@link SHA1withDSADigitalSignature_SUN},
3377 * {@link RIPEMD160withRSADigitalSignature_Mindbright}</LI>
3378 * <LI>Algoritmo criptográfico de protección asimétrica:
3379 * {@link RSAwithOAEPwithMD5andMGF1PaddingAsymmetricProtection_SunJCE},
3380 * {@link RSAAsymmetricProtection_LogiCrypto}</LI>
3381 * <LI>Algoritmo criptográfico de protección simétrica de bloques:
3382 * {@link BlowfishBlockSymmetricProtection_SunJCE},
3383 * {@link BlowfishBlockSymmetricProtection_LogiCrypto},
3384 * {@link CAST5BlockSymmetricProtection_Mindbright}</LI>
3385 * <LI>Algoritmo criptográfico de protección simétrica de flujo:
3386 * {@link RC4StreamSymmetricProtection_SunJCE},
3387 * {@link RC4StreamSymmetricProtection_Mindbright}</LI>
3388 * <LI>Algoritmo criptográfico de protección basada en contraseña:
3389 * {@link PBEwithMD5andDESPBEProtection_SunJCE}</LI>
3390 * </UL>
3391 * </LI>
3392 * </UL>
3393 * <UL>
3394 * Para añadir nuevos algoritmos JCE es necesario heredar de algunas de las
3395 * clases.
3396 * <LI>Algoritmo traductor de claves asimétricas:
3397 * <UL>
3398 * <LI>Superclase: {@link KeyFactorySpi}</LI>
3399 * <LI>Ejemplos: {@link AsymmetricKeyTranslator_JCESpiAdapter},
3400 * {@link AsymmetricKeyGenerator_JCESpiAdapterDefaultTestCase}</LI>
3401 * </UL>
3402 * </LI>
3403 * <LI>Algoritmo traductor de claves simétricas:
3404 * <UL>
3405 * <LI>Superclase: {@link SecretKeyFactorySpi}</LI>
3406 * <LI>Ejemplos: {@link SymmetricKeyTranslator_JCESpiAdapter},
3407 * {@link SymmetricKeyTranslator_JCESpiAdapterDefaultTestCase}</LI>
3408 * </UL>
3409 * </LI>
3410 * <LI>Algoritmo traductor de parámetros:
3411 * <UL>
3412 * <LI>Superclase: {@link AlgorithmParametersSpi}</LI>
3413 * <LI>Ejemplos: {@link ParameterTranslator_JCESpiAdapter},
3414 * {@link ParameterTranslator_JCESpiAdapterDefaultTestCase}</LI>
3415 * </UL>
3416 * </LI>
3417 * <LI>Algoritmo generador de claves asimétricas:
3418 * <UL>
3419 * <LI>Superclase: {@link KeyPairGeneratorSpi}</LI>
3420 * <LI>Ejemplos: {@link AsymmetricKeyGenerator_JCESpiAdapter},
3421 * {@link AsymmetricKeyGenerator_JCESpiAdapterDefaultTestCase}</LI>
3422 * </UL>
3423 * </LI>
3424 * <LI>Algoritmo generador de claves simétricas:
3425 * <UL>
3426 * <LI>Superclase: {@link KeyGeneratorSpi}</LI>
3427 * <LI>Ejemplos: {@link SymmetricKeyGenerator_JCESpiAdapter},
3428 * {@link SymmetricKeyGenerator_JCESpiAdapterDefaultTestCase}</LI>
3429 * </UL>
3430 * </LI>
3431 * <LI>Algoritmo generador de parámetros:
3432 * <UL>
3433 * <LI>Superclase: {@link AlgorithmParameterGeneratorSpi}</LI>
3434 * <LI>Ejemplos: {@link ParameterGenerator_JCESpiAdapter},
3435 * {@link ParameterGenerator_JCESpiAdapterDefaultTestCase}</LI>
3436 * </UL>
3437 * </LI>
3438 * <LI>Algoritmo generador de datos aleatorios:
3439 * <UL>
3440 * <LI>Superclase: {@link SecureRandomSpi}</LI>
3441 * <LI>Ejemplos: {@link SecureRandomGenerator_JCESpiAdapter},
3442 * {@link SecureRandomGenerator_JCESpiAdapterDefaultTestCase}</LI>
3443 * </UL>
3444 * </LI>
3445 * <LI>Algoritmo criptográfico de autentificación mediante huellas digitales:
3446 * <UL>
3447 * <LI>Superclase: {@link MessageDigestSpi}</LI>
3448 * <LI>Ejemplos: {@link FingerPrint_JCESpiAdapter},
3449 * {@link FingerPrint_JCESpiAdapterDefaultTestCase}</LI>
3450 * </UL>
3451 * </LI>
3452 * <LI>Algoritmo criptográfico de autentificación mediante sellos digitales:
3453 * <UL>
3454 * <LI>Superclase: {@link MacSpi}</LI>
3455 * <LI>Ejemplos: {@link DigitalSeal_JCESpiAdapter},
3456 * {@link DigitalSeal_JCESpiAdapterDefaultTestCase}</LI>
3457 * </UL>
3458 * </LI>
3459 * <LI>Algoritmo criptográfico de autentificación mediante firmas digitales:
3460 * <UL>
3461 * <LI>Superclase: {@link SignatureSpi}</LI>
3462 * <LI>Ejemplos: {@link DigitalSignature_JCESpiAdapter},
3463 * {@link DigitalSignature_JCESpiAdapterDefaultTestCase}</LI>
3464 * </UL>
3465 * </LI>
3466 * <LI>Algoritmo criptográfico de protección:
3467 * <UL>
3468 * <LI>Superclase: {@link CipherSpi}</LI>
3469 * <LI>Ejemplos: {@link Protection_JCESpiAdapter},
3470 * {@link Protection_JCESpiAdapterDefaultTestCase}</LI>
3471 * </UL>
3472 * </LI>
3473 * </LI>
3474 */
3475 public static class DefiningAlgorithms {
3476 }
3477
3478 /**
3479 * Muestra cómo obtener información de inicialización e inicializar los
3480 * algoritmos JCEF y JCE
3481 */
3482 public static class Initiation {
3483
3484 /**
3485 * Mediante JCE, obtiene los parámetros de inicialización de un algoritmo
3486 * generador de parámetros
3487 *
3488 * @param algorithm
3489 * Algoritmo generador de parámetros
3490 * @return Parámetros de inicialización
3491 * @see AlgorithmParameterGenerator#getAlgorithm()
3492 * @see AlgorithmParameterGenerator#getProvider()
3493 * @see AlgorithmParameterGenerator
3494 * @see #getInitiationInfo_JCEF(ParameterGenerator)
3495 */
3496 public static Map getInitiationInfo_JCE(
3497 AlgorithmParameterGenerator algorithm) {
3498 Map result = null;
3499 result = new HashMap();
3500 String name = algorithm.getAlgorithm();
3501 Provider provider = algorithm.getProvider();
3502 result.put("name", name);
3503 result.put("provider", provider);
3504 return result;
3505 }
3506
3507 /**
3508 * Mediante JCE, obtiene los parámetros de inicialización de un algoritmo
3509 * traductor de parámetros
3510 *
3511 * @param algorithm
3512 * Algoritmo traductor de parámetros
3513 * @return Parámetros de inicialización
3514 * @see AlgorithmParameters#getAlgorithm()
3515 * @see AlgorithmParameters#getProvider()
3516 * @see AlgorithmParameters
3517 * @see #getInitiationInfo_JCEF(ParameterTranslator)
3518 */
3519 public static Map getInitiationInfo_JCE(AlgorithmParameters algorithm) {
3520 Map result = null;
3521 result = new HashMap();
3522 String name = algorithm.getAlgorithm();
3523 Provider provider = algorithm.getProvider();
3524 result.put("name", name);
3525 result.put("provider", provider);
3526 return result;
3527 }
3528
3529 /**
3530 * Mediante JCE, obtiene los parámetros de inicialización de un algoritmo
3531 * criptográfico de protección
3532 *
3533 * @param algorithm
3534 * Algoritmo criptográfico de protección
3535 * @return Parámetros de inicialización
3536 * @see Cipher#getAlgorithm()
3537 * @see Cipher#getProvider()
3538 */
3539 public static Map getInitiationInfo_JCE(Cipher algorithm) {
3540 Map result = null;
3541 result = new HashMap();
3542 String name = algorithm.getAlgorithm();
3543 Provider provider = algorithm.getProvider();
3544 result.put("name", name);
3545 result.put("provider", provider);
3546 return result;
3547 }
3548
3549 /**
3550 * Mediante JCE, obtiene los parámetros de inicialización de un algoritmo
3551 * generador de claves simétricas
3552 *
3553 * @param algorithm
3554 * Algoritmo generador de claves simétricas
3555 * @return Parámetros de inicialización
3556 * @see javax.crypto.KeyGenerator#getAlgorithm()
3557 * @see javax.crypto.KeyGenerator#getProvider()
3558 * @see javax.crypto.KeyGenerator
3559 * @see #getInitiationInfo_JCEF(SymmetricKeyGenerator)
3560 */
3561 public static Map getInitiationInfo_JCE(javax.crypto.KeyGenerator algorithm) {
3562 Map result = null;
3563 result = new HashMap();
3564 String name = algorithm.getAlgorithm();
3565 Provider provider = algorithm.getProvider();
3566 result.put("name", name);
3567 result.put("provider", provider);
3568 return result;
3569 }
3570
3571 /**
3572 * Mediante JCE, obtiene los parámetros de inicialización de un algoritmo
3573 * traductor de claves asimétricas
3574 *
3575 * @param algorithm
3576 * Algoritmo traductor de claves asimétricas
3577 * @return Parámetros de inicialización
3578 * @see KeyFactory#getAlgorithm()
3579 * @see KeyFactory#getProvider()
3580 * @see KeyFactory
3581 * @see #getInitiationInfo_JCEF(AsymmetricKeyTranslator)
3582 */
3583 public static Map getInitiationInfo_JCE(KeyFactory algorithm) {
3584 Map result = null;
3585 result = new HashMap();
3586 String name = algorithm.getAlgorithm();
3587 Provider provider = algorithm.getProvider();
3588 result.put("name", name);
3589 result.put("provider", provider);
3590 return result;
3591 }
3592
3593 /**
3594 * Mediante JCE, obtiene los parámetros de inicialización de un algoritmo
3595 * generador de claves asimétricas
3596 *
3597 * @param algorithm
3598 * Algoritmo generador de claves asimétricas
3599 * @return Parámetros de inicialización
3600 * @see KeyPairGenerator#getAlgorithm()
3601 * @see KeyPairGenerator#getProvider()
3602 * @see KeyPairGenerator
3603 * @see #getInitiationInfo_JCEF(AsymmetricKeyGenerator)
3604 */
3605 public static Map getInitiationInfo_JCE(KeyPairGenerator algorithm) {
3606 Map result = null;
3607 result = new HashMap();
3608 String name = algorithm.getAlgorithm();
3609 Provider provider = algorithm.getProvider();
3610 result.put("name", name);
3611 result.put("provider", provider);
3612 return result;
3613 }
3614
3615 /**
3616 * Mediante JCE, obtiene los parámetros de inicialización de un algoritmo
3617 * criptográfico de autentificación mediante sellos digitales
3618 *
3619 * @param algorithm
3620 * Algoritmo criptográfico de autentificación mediante sellos
3621 * digitales
3622 * @return Parámetros de inicialización
3623 * @see Mac#getAlgorithm()
3624 * @see Mac#getProvider()
3625 */
3626 public static Map getInitiationInfo_JCE(Mac algorithm) {
3627 Map result = null;
3628 result = new HashMap();
3629 String name = algorithm.getAlgorithm();
3630 Provider provider = algorithm.getProvider();
3631 result.put("name", name);
3632 result.put("provider", provider);
3633 return result;
3634 }
3635
3636 /**
3637 * Mediante JCE, obtiene los parámetros de inicialización de un algoritmo
3638 * criptográfico de autentificación mediante huellas digitales
3639 *
3640 * @param algorithm
3641 * Algoritmo criptográfico de autentificación mediante huellas
3642 * digitales
3643 * @return Parámetros de inicialización
3644 * @see MessageDigest#getAlgorithm()
3645 * @see MessageDigest#getProvider()
3646 * @see MessageDigest
3647 * @see #getInitiationInfo_JCEF(FingerPrint)
3648 */
3649 public static Map getInitiationInfo_JCE(MessageDigest algorithm) {
3650 Map result = null;
3651 result = new HashMap();
3652 String name = algorithm.getAlgorithm();
3653 Provider provider = algorithm.getProvider();
3654 result.put("name", name);
3655 result.put("provider", provider);
3656 return result;
3657 }
3658
3659 /**
3660 * Mediante JCE, obtiene los parámetros de inicialización de un algoritmo
3661 * traductor de claves simétricas
3662 *
3663 * @param algorithm
3664 * Algoritmo traductor de claves simétricas
3665 * @return Parámetros de inicialización
3666 * @see SecretKeyFactory#getAlgorithm()
3667 * @see SecretKeyFactory#getProvider()
3668 * @see SecretKeyFactory
3669 * @see #getInitiationInfo_JCEF(SymmetricKeyTranslator)
3670 */
3671 public static Map getInitiationInfo_JCE(SecretKeyFactory algorithm) {
3672 Map result = null;
3673 result = new HashMap();
3674 String name = algorithm.getAlgorithm();
3675 Provider provider = algorithm.getProvider();
3676 result.put("name", name);
3677 result.put("provider", provider);
3678 return result;
3679 }
3680
3681 /**
3682 * Mediante JCE, obtiene los parámetros de inicialización de un algoritmo
3683 * generador de datos aleatorios
3684 *
3685 * @param algorithm
3686 * Algoritmo generador de datos aleatorios
3687 * @return Parámetros de inicialización
3688 * @see SecureRandom#getAlgorithm()
3689 * @see SecureRandom#getProvider()
3690 * @see SecureRandom
3691 * @see #getInitiationInfo_JCEF(SecureRandomGenerator)
3692 */
3693 public static Map getInitiationInfo_JCE(SecureRandom algorithm) {
3694 Map result = null;
3695 result = new HashMap();
3696 String name = algorithm.getAlgorithm();
3697 Provider provider = algorithm.getProvider();
3698 result.put("name", name);
3699 result.put("provider", provider);
3700 return result;
3701 }
3702
3703 /**
3704 * Mediante JCE, obtiene los parámetros de inicialización de un algoritmo
3705 * criptográfico de autentificación mediante firmas digitales
3706 *
3707 * @param algorithm
3708 * Algoritmo criptográfico de autentificación mediante firmas
3709 * digitales
3710 * @return Parámetros de inicialización
3711 * @see Signature#getAlgorithm()
3712 * @see Signature#getProvider()
3713 */
3714 public static Map getInitiationInfo_JCE(Signature algorithm) {
3715 Map result = null;
3716 result = new HashMap();
3717 String name = algorithm.getAlgorithm();
3718 Provider provider = algorithm.getProvider();
3719 result.put("name", name);
3720 result.put("provider", provider);
3721 return result;
3722 }
3723
3724 /**
3725 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
3726 *
3727 * @param algorithm
3728 * Algoritmo
3729 * @return Parámetros de inicialización
3730 * @see Algorithm#getAdditionalParameter()
3731 * @see Algorithm
3732 * @see #getInitiationInfo(JCEFObject)
3733 * @see #getInitiationInfo(Generator)
3734 * @see #getInitiationInfo(Translator)
3735 * @see #getInitiationInfo(CryptoAlgorithm)
3736 */
3737 public static Map getInitiationInfo_JCEF(Algorithm algorithm) {
3738 Map result = getInitiationInfo_JCEF((JCEFObject) algorithm);
3739 AlgorithmParameterSpec additionalParameter = algorithm
3740 .getAdditionalParameter();
3741 result.put("additionalParameter", additionalParameter);
3742 return result;
3743 }
3744
3745 /**
3746 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
3747 * generador de claves asimétricas
3748 *
3749 * @param algorithm
3750 * Algoritmo generador de claves asimétricas
3751 * @return Parámetros de inicialización
3752 * @see AsymmetricKeyGenerator
3753 * @see #getInitiationInfo_JCEF(KeyGenerator)
3754 */
3755 public static Map getInitiationInfo_JCEF(AsymmetricKeyGenerator algorithm) {
3756 Map result = getInitiationInfo_JCEF((KeyGenerator) algorithm);
3757 return result;
3758 }
3759
3760 /**
3761 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
3762 * traductor de claves asimétricas
3763 *
3764 * @param algorithm
3765 * Algoritmo traductor de claves asimétricas
3766 * @return Parámetros de inicialización
3767 * @see AsymmetricKeyTranslator
3768 * @see #getInitiationInfo_JCEF(KeyTranslator)
3769 * @see #getInitiationInfo_JCE(KeyFactory)
3770 */
3771 public static Map getInitiationInfo_JCEF(AsymmetricKeyTranslator algorithm) {
3772 Map result = getInitiationInfo_JCEF((KeyTranslator) algorithm);
3773 return result;
3774 }
3775
3776 /**
3777 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
3778 * criptográfico de protección asimétrica
3779 *
3780 * @param algorithm
3781 * Algoritmo criptográfico de protección asimétrica
3782 * @return Parámetros de inicialización
3783 * @throws Throwable
3784 * Ocurre si no se ha podido realizar la operación
3785 * @see AsymmetricProtection#getProtectKey()
3786 * @see AsymmetricProtection#getProtectKeySpec()
3787 * @see AsymmetricProtection#getUnprotectKey()
3788 * @see AsymmetricProtection#getUnprotectKeySpec()
3789 * @see AsymmetricProtection
3790 * @see #getInitiationInfo_JCEF(Protection)
3791 */
3792 public static Map getInitiationInfo_JCEF(AsymmetricProtection algorithm)
3793 throws Throwable {
3794 Map result = getInitiationInfo_JCEF((Protection) algorithm);
3795 PublicKey protectKey = algorithm.getProtectKey();
3796 KeySpec protectKeySpec = algorithm.getProtectKeySpec();
3797 PrivateKey unprotectKey = algorithm.getUnprotectKey();
3798 KeySpec unprotectKeySpec = algorithm.getUnprotectKeySpec();
3799 result.put("protectKey", protectKey);
3800 result.put("protectKeySpec", protectKeySpec);
3801 result.put("unprotectKey", unprotectKey);
3802 result.put("unprotectKeySpec", unprotectKeySpec);
3803 return result;
3804 }
3805
3806 /**
3807 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
3808 * criptográfico de autentificación
3809 *
3810 * @param algorithm
3811 * Algoritmo criptográfico de autentificación
3812 * @return Parámetros de inicialización
3813 * @throws Throwable
3814 * Ocurre si no se ha podido realizar la operación
3815 * @see AuthenticationAlgorithm
3816 * @see #getInitiationInfo_JCEF(CryptoAlgorithm)
3817 * @see #getInitiationInfo_JCEF(FingerPrint)
3818 * @see #getInitiationInfo_JCEF(DigitalSeal)
3819 * @see #getInitiationInfo_JCEF(DigitalSignature)
3820 */
3821 public static Map getInitiationInfo_JCEF(AuthenticationAlgorithm algorithm)
3822 throws Throwable {
3823 Map result = getInitiationInfo_JCEF((CryptoAlgorithm) algorithm);
3824 return result;
3825 }
3826
3827 /**
3828 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
3829 * criptográfico de protección simétrica de bloques
3830 *
3831 * @param algorithm
3832 * Algoritmo criptográfico de protección simétrica de bloques
3833 * @return Parámetros de inicialización
3834 * @throws Throwable
3835 * Ocurre si no se ha podido realizar la operación
3836 * @see BlockSymmetricProtection
3837 * @see #getInitiationInfo_JCEF(SymmetricProtection)
3838 */
3839 public static Map getInitiationInfo_JCEF(BlockSymmetricProtection algorithm)
3840 throws Throwable {
3841 Map result = getInitiationInfo_JCEF((SymmetricProtection) algorithm);
3842 return result;
3843 }
3844
3845 /**
3846 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
3847 * criptográfico
3848 *
3849 * @param algorithm
3850 * Algoritmo criptográfico
3851 * @return Parámetros de inicialización
3852 * @throws Throwable
3853 * Ocurre si no se ha podido realizar la operación
3854 * @see CryptoAlgorithm#getParameter()
3855 * @see CryptoAlgorithm#getEncodedParameter()
3856 * @see CryptoAlgorithm#getEncodedParameter(String)
3857 * @see CryptoAlgorithm
3858 * @see #getInitiationInfo_JCEF(Algorithm)
3859 * @see #getInitiationInfo_JCEF(AuthenticationAlgorithm)
3860 * @see #getInitiationInfo_JCEF(Protection)
3861 */
3862 public static Map getInitiationInfo_JCEF(CryptoAlgorithm algorithm)
3863 throws Throwable {
3864 Map result = getInitiationInfo_JCEF((Algorithm) algorithm);
3865 AlgorithmParameterSpec parameter = algorithm.getParameter();
3866 byte[] encodedParameter = algorithm.getEncodedParameter();
3867 String format = "otherFormat";
3868 byte[] encodedParameterWithFormat = algorithm
3869 .getEncodedParameter(format);
3870 result.put("parameter", parameter);
3871 result.put("encodedParameter", encodedParameter);
3872 result.put("encodedParameterWithFormat", encodedParameterWithFormat);
3873 return result;
3874 }
3875
3876 /**
3877 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
3878 * criptográfico de autentificación mediante sellos digitales basados en
3879 * contraseña
3880 *
3881 * @param algorithm
3882 * Algoritmo criptográfico de autentificación mediante sellos
3883 * digitales basados en contraseña
3884 * @return Parámetros de inicialización
3885 * @throws Throwable
3886 * Ocurre si no se ha podido realizar la operación
3887 * @see DigitalPBESeal#getPassword()
3888 * @see DigitalPBESeal
3889 * @see #getInitiationInfo_JCEF(DigitalSeal)
3890 */
3891 public static Map getInitiationInfo_JCEF(DigitalPBESeal algorithm)
3892 throws Throwable {
3893 Map result = getInitiationInfo_JCEF((AuthenticationAlgorithm) algorithm);
3894 char[] password = algorithm.getPassword();
3895 result.put("password", password);
3896 return result;
3897 }
3898
3899 /**
3900 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
3901 * criptográfico de autentificación mediante sellos digitales
3902 *
3903 * @param algorithm
3904 * Algoritmo criptográfico de autentificación mediante sellos
3905 * digitales
3906 * @return Parámetros de inicialización
3907 * @throws Throwable
3908 * Ocurre si no se ha podido realizar la operación
3909 * @see DigitalSeal#getSymmetricKey()
3910 * @see DigitalSeal#getSymmetricKeySpec()
3911 * @see DigitalSeal
3912 * @see #getInitiationInfo_JCEF(AuthenticationAlgorithm)
3913 * @see #getInitiationInfo_JCEF(DigitalPBESeal)
3914 */
3915 public static Map getInitiationInfo_JCEF(DigitalSeal algorithm)
3916 throws Throwable {
3917 Map result = getInitiationInfo_JCEF((AuthenticationAlgorithm) algorithm);
3918 SecretKey symmetricKey = algorithm.getSymmetricKey();
3919 KeySpec symmetricKeySpec = algorithm.getSymmetricKeySpec();
3920 result.put("symmetricKey", symmetricKey);
3921 result.put("symmetricKeySpec", symmetricKeySpec);
3922 return result;
3923 }
3924
3925 /**
3926 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
3927 * criptográfico de autentificación mediante firmas digitales
3928 *
3929 * @param algorithm
3930 * Algoritmo criptográfico de autentificación mediante firmas
3931 * digitales
3932 * @return Parámetros de inicialización
3933 * @throws Throwable
3934 * Ocurre si no se ha podido realizar la operación
3935 * @see DigitalSignature#getSigningKey()
3936 * @see DigitalSignature#getSigningKeySpec()
3937 * @see DigitalSignature#getVerifyKey()
3938 * @see DigitalSignature#getVerifyKeySpec()
3939 * @see DigitalSignature
3940 * @see #getInitiationInfo_JCEF(AuthenticationAlgorithm)
3941 */
3942 public static Map getInitiationInfo_JCEF(DigitalSignature algorithm)
3943 throws Throwable {
3944 Map result = getInitiationInfo_JCEF((AuthenticationAlgorithm) algorithm);
3945 PublicKey verifyKey = algorithm.getVerifyKey();
3946 KeySpec verifyKeySpec = algorithm.getVerifyKeySpec();
3947 PrivateKey signingKey = algorithm.getSigningKey();
3948 KeySpec signingKeySpec = algorithm.getSigningKeySpec();
3949 result.put("verifyKey", verifyKey);
3950 result.put("verifyKeySpec", verifyKeySpec);
3951 result.put("signingKey", signingKey);
3952 result.put("signingKeySpec", signingKeySpec);
3953 return result;
3954 }
3955
3956 /**
3957 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
3958 * criptográfico de autentificación mediante huellas digitales
3959 *
3960 * @param algorithm
3961 * Algoritmo criptográfico de autentificación mediante huellas
3962 * digitales
3963 * @return Parámetros de inicialización
3964 * @throws Throwable
3965 * Ocurre si no se ha podido realizar la operación
3966 * @see FingerPrint
3967 * @see #getInitiationInfo_JCEF(AuthenticationAlgorithm)
3968 * @see #getInitiationInfo_JCE(MessageDigest)
3969 */
3970 public static Map getInitiationInfo_JCEF(FingerPrint algorithm)
3971 throws Throwable {
3972 Map result = getInitiationInfo_JCEF((AuthenticationAlgorithm) algorithm);
3973 return result;
3974 }
3975
3976 /**
3977 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
3978 * generador
3979 *
3980 * @param algorithm
3981 * Algoritmo generador
3982 * @return Parámetros de inicialización
3983 * @see Generator#getRandom()
3984 * @see Generator#getGenParameter()
3985 * @see Generator
3986 * @see #getInitiationInfo_JCEF(Algorithm)
3987 * @see #getInitiationInfo_JCEF(KeyGenerator)
3988 * @see #getInitiationInfo_JCEF(ParameterGenerator)
3989 * @see #getInitiationInfo_JCEF(SecureRandomGenerator)
3990 */
3991 public static Map getInitiationInfo_JCEF(Generator algorithm) {
3992 Map result = getInitiationInfo_JCEF((Algorithm) algorithm);
3993 SecureRandom secureRandom = algorithm.getRandom();
3994 AlgorithmParameterSpec genParameter = algorithm.getGenParameter();
3995 result.put("random", secureRandom);
3996 result.put("genParameter", genParameter);
3997 return result;
3998 }
3999
4000 /**
4001 * Mediante JCEF, obtiene los parámetros de inicialización de un objeto
4002 *
4003 * @param object
4004 * Objeto
4005 * @return Parámetros de inicialización
4006 * @see JCEFObject
4007 * @see #getInitiationInfo_JCEF(Algorithm)
4008 * @see #getInitiationInfo_JCEF(JCEFProvider)
4009 */
4010 public static Map getInitiationInfo_JCEF(JCEFObject object) {
4011 Map result = new HashMap();
4012 return result;
4013 }
4014
4015 /**
4016 * Mediante JCEF, obtiene los parámetros de inicialización de un proveedor
4017 *
4018 * @param provider
4019 * Proveedor
4020 * @return Parámetros de inicialización
4021 * @see JCEFProvider
4022 * @see #getInitiationInfo_JCEF(JCEFObject)
4023 */
4024 public static Map getInitiationInfo_JCEF(JCEFProvider provider) {
4025 Map result = getInitiationInfo_JCEF((JCEFObject) provider);
4026 return result;
4027 }
4028
4029 /**
4030 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
4031 * generador de claves
4032 *
4033 * @param algorithm
4034 * Algoritmo generador de claves
4035 * @return Parámetros de inicialización
4036 * @see KeyGenerator#getKeySize()
4037 * @see KeyGenerator
4038 * @see #getInitiationInfo_JCEF(Generator)
4039 * @see #getInitiationInfo_JCEF(AsymmetricKeyGenerator)
4040 * @see #getInitiationInfo_JCEF(SymmetricKeyGenerator)
4041 */
4042 public static Map getInitiationInfo_JCEF(KeyGenerator algorithm) {
4043 Map result = getInitiationInfo_JCEF((Generator) algorithm);
4044 int keySize = algorithm.getKeySize();
4045 result.put("keySize", new Integer(keySize));
4046 return result;
4047 }
4048
4049 /**
4050 * Mediante JCEF, obtiene los parámetros de inicialización de un traductor
4051 * de claves
4052 *
4053 * @param algorithm
4054 * Algoritmo traductor de claves
4055 * @return Parámetros de inicialización
4056 * @see KeyTranslator
4057 * @see #getInitiationInfo_JCEF(Translator)
4058 * @see #getInitiationInfo_JCEF(AsymmetricKeyTranslator)
4059 * @see #getInitiationInfo_JCEF(SymmetricKeyTranslator)
4060 */
4061 public static Map getInitiationInfo_JCEF(KeyTranslator algorithm) {
4062 Map result = getInitiationInfo_JCEF((Translator) algorithm);
4063 return result;
4064 }
4065
4066 /**
4067 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
4068 * generador de parámetros
4069 *
4070 * @param algorithm
4071 * Algoritmo generador de parámetros
4072 * @return Parámetros de inicialización
4073 * @see ParameterGenerator#getParameterSize()
4074 * @see ParameterGenerator
4075 * @see #getInitiationInfo_JCEF(Generator)
4076 * @see #getInitiationInfo_JCE(AlgorithmParameterGenerator)
4077 */
4078 public static Map getInitiationInfo_JCEF(ParameterGenerator algorithm) {
4079 Map result = getInitiationInfo_JCEF((Generator) algorithm);
4080 int parameterSize = algorithm.getParameterSize();
4081 result.put("parameterSize", new Integer(parameterSize));
4082 return result;
4083 }
4084
4085 /**
4086 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
4087 * traductor de parámetros
4088 *
4089 * @param algorithm
4090 * Algoritmo traductor de parámetros
4091 * @return Parámetros de inicialización
4092 * @see ParameterTranslator
4093 * @see #getInitiationInfo_JCEF(Translator)
4094 * @see #getInitiationInfo_JCE(AlgorithmParameters)
4095 */
4096 public static Map getInitiationInfo_JCEF(ParameterTranslator algorithm) {
4097 Map result = getInitiationInfo_JCEF((Translator) algorithm);
4098 return result;
4099 }
4100
4101 /**
4102 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
4103 * criptográfico de protección basada en contraseña
4104 *
4105 * @param algorithm
4106 * Algoritmo criptográfico de protección basada en contraseña
4107 * @return Parámetros de inicialización
4108 * @throws Throwable
4109 * Ocurre si no se ha podido realizar la operación
4110 * @see PBEProtection#getPassword()
4111 * @see PBEProtection
4112 * @see #getInitiationInfo_JCEF(SymmetricProtection)
4113 */
4114 public static Map getInitiationInfo_JCEF(PBEProtection algorithm)
4115 throws Throwable {
4116 Map result = getInitiationInfo_JCEF((SymmetricProtection) algorithm);
4117 char[] password = algorithm.getPassword();
4118 result.put("password", password);
4119 return result;
4120 }
4121
4122 /**
4123 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
4124 * criptográfico de protección
4125 *
4126 * @param algorithm
4127 * Algoritmo criptográfico de protección
4128 * @return Parámetros de inicialización
4129 * @throws Throwable
4130 * Ocurre si no se ha podido realizar la operación
4131 * @see Protection
4132 * @see #getInitiationInfo_JCEF(CryptoAlgorithm)
4133 */
4134 public static Map getInitiationInfo_JCEF(Protection algorithm)
4135 throws Throwable {
4136 Map result = getInitiationInfo_JCEF((CryptoAlgorithm) algorithm);
4137 return result;
4138 }
4139
4140 /**
4141 * Mediante JCEF, obtiene los parámetros de inicialización de un generador
4142 * de datos aleatorios
4143 *
4144 * @param algorithm
4145 * Algoritmo generador de datos aleatorios
4146 * @return Parámetros de inicialización
4147 * @see SecureRandomGenerator#getSeed()
4148 * @see SecureRandomGenerator
4149 * @see #getInitiationInfo_JCEF(Generator)
4150 * @see #getInitiationInfo_JCE(SecureRandom)
4151 */
4152 public static Map getInitiationInfo_JCEF(SecureRandomGenerator algorithm) {
4153 Map result = getInitiationInfo_JCEF((Generator) algorithm);
4154 byte[] seed = algorithm.getSeed();
4155 result.put("seed", seed);
4156 return result;
4157 }
4158
4159 /**
4160 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
4161 * criptográfico de protección simétrica de flujo
4162 *
4163 * @param algorithm
4164 * Algoritmo criptográfico de protección simétrica de flujo
4165 * @return Parámetros de inicialización
4166 * @throws Throwable
4167 * Ocurre si no se ha podido realizar la operación
4168 */
4169 public static Map getInitiationInfo_JCEF(StreamSymmetricProtection algorithm)
4170 throws Throwable {
4171 Map result = getInitiationInfo_JCEF((SymmetricProtection) algorithm);
4172 return result;
4173 }
4174
4175 /**
4176 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
4177 * generador de claves simétricas
4178 *
4179 * @param algorithm
4180 * Algoritmo generador de claves simétricas
4181 * @return Parámetros de inicialización
4182 * @see SymmetricKeyGenerator
4183 * @see #getInitiationInfo_JCEF(KeyGenerator)
4184 * @see #getInitiationInfo_JCE(javax.crypto.KeyGenerator)
4185 */
4186 public static Map getInitiationInfo_JCEF(SymmetricKeyGenerator algorithm) {
4187 Map result = getInitiationInfo_JCEF((KeyGenerator) algorithm);
4188 return result;
4189 }
4190
4191 /**
4192 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
4193 * traductor de claves simétricas
4194 *
4195 * @param algorithm
4196 * Algoritmo traductor de claves simétricas
4197 * @return Parámetros de inicialización
4198 * @see SymmetricKeyTranslator
4199 * @see #getInitiationInfo_JCEF(KeyTranslator)
4200 * @see #getInitiationInfo_JCE(SecretKeyFactory)
4201 */
4202 public static Map getInitiationInfo_JCEF(SymmetricKeyTranslator algorithm) {
4203 Map result = getInitiationInfo_JCEF((KeyTranslator) algorithm);
4204 return result;
4205 }
4206
4207 /**
4208 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
4209 * criptográfico de protección simétrica
4210 *
4211 * @param algorithm
4212 * Algoritmo criptográfico de protección simétrica
4213 * @return Parámetros de inicialización
4214 * @throws Throwable
4215 * Ocurre si no se ha podido realizar la operación
4216 * @see SymmetricProtection#getSymmetricKey()
4217 * @see SymmetricProtection#getSymmetricKeySpec()
4218 * @see SymmetricProtection
4219 * @see #getInitiationInfo_JCEF(Protection)
4220 * @see #getInitiationInfo_JCEF(BlockSymmetricProtection)
4221 * @see #getInitiationInfo_JCEF(StreamSymmetricProtection)
4222 * @see #getInitiationInfo_JCEF(PBEProtection)
4223 */
4224 public static Map getInitiationInfo_JCEF(SymmetricProtection algorithm)
4225 throws Throwable {
4226 Map result = getInitiationInfo_JCEF((Protection) algorithm);
4227 SecretKey symmetricKey = algorithm.getSymmetricKey();
4228 KeySpec symmetricKeySpec = algorithm.getSymmetricKeySpec();
4229 result.put("symmetricKey", symmetricKey);
4230 result.put("symmetricKeySpec", symmetricKeySpec);
4231 return result;
4232 }
4233
4234 /**
4235 * Mediante JCEF, obtiene los parámetros de inicialización de un algoritmo
4236 * traductor
4237 *
4238 * @param algorithm
4239 * Algoritmo traductor
4240 * @return Parámetros de inicialización
4241 * @see Translator
4242 * @see #getInitiationInfo_JCEF(Algorithm)
4243 * @see #getInitiationInfo_JCEF(KeyTranslator)
4244 * @see #getInitiationInfo_JCEF(ParameterTranslator)
4245 */
4246 public static Map getInitiationInfo_JCEF(Translator algorithm) {
4247 Map result = getInitiationInfo_JCEF((Algorithm) algorithm);
4248 return result;
4249 }
4250
4251 /**
4252 * Mediante JCE, inicializa de forma específica un algoritmo generador de
4253 * parámetros
4254 *
4255 * @param algorithm
4256 * Algoritmo generador de parámetros
4257 * @param genParameter
4258 * Parámetro de inicialización para
4259 * {@link AlgorithmParameterGenerator#init(java.security.spec.AlgorithmParameterSpec)}
4260 * o
4261 * {@link AlgorithmParameterGenerator#init(java.security.spec.AlgorithmParameterSpec, java.security.SecureRandom)}
4262 * @param parameterSize
4263 * Parámetro de inicialización para
4264 * {@link AlgorithmParameterGenerator#init(int)} o
4265 * {@link AlgorithmParameterGenerator#init(int, java.security.SecureRandom)}
4266 * @param random
4267 * Parámetro de inicialización para
4268 * {@link AlgorithmParameterGenerator#init(int, java.security.SecureRandom)}
4269 * o
4270 * {@link AlgorithmParameterGenerator#init(java.security.spec.AlgorithmParameterSpec, java.security.SecureRandom)}
4271 * @throws InvalidAlgorithmParameterException
4272 * @see AlgorithmParameterGenerator#init(int)
4273 * @see AlgorithmParameterGenerator#init(int, java.security.SecureRandom)
4274 * @see AlgorithmParameterGenerator#init(java.security.spec.AlgorithmParameterSpec)
4275 * @see AlgorithmParameterGenerator#init(java.security.spec.AlgorithmParameterSpec,
4276 * java.security.SecureRandom)
4277 * @see AlgorithmParameterGenerator
4278 * @see #setInitiationInfo_JCE(AlgorithmParameterGenerator, Map)
4279 */
4280 public static void initiate_JCE(AlgorithmParameterGenerator algorithm,
4281 AlgorithmParameterSpec genParameter, int parameterSize,
4282 SecureRandom random) throws InvalidAlgorithmParameterException {
4283 if (genParameter != null && random == null) {
4284 algorithm.init(genParameter);
4285 } else if (genParameter != null && random != null) {
4286 algorithm.init(genParameter, random);
4287 } else if (genParameter == null && random == null) {
4288 algorithm.init(parameterSize);
4289 } else if (genParameter == null && random != null) {
4290 algorithm.init(parameterSize, random);
4291 }
4292 }
4293
4294 /**
4295 * Mediante JCE, inicializa de forma específica un algoritmo traductor de
4296 * parámetros
4297 *
4298 * @param algorithm
4299 * Algoritmo traductor de parámetros
4300 * @param parameter
4301 * Parámetro de inicialización para
4302 * {@link AlgorithmParameters#init(java.security.spec.AlgorithmParameterSpec)}
4303 * o {@link AlgorithmParameters#init(byte[])} o
4304 * {@link AlgorithmParameters#init(byte[], java.lang.String)}
4305 * @param format
4306 * Parámetro de inicialización para
4307 * {@link AlgorithmParameters#init(byte[], java.lang.String)}
4308 * @throws Throwable
4309 * @see AlgorithmParameters#init(java.security.spec.AlgorithmParameterSpec)
4310 * @see AlgorithmParameters#init(byte[])
4311 * @see AlgorithmParameters#init(byte[], java.lang.String)
4312 * @see AlgorithmParameters
4313 * @see #setInitiationInfo_JCE(AlgorithmParameters, Map)
4314 */
4315 public static void initiate_JCE(AlgorithmParameters algorithm,
4316 Object parameter, String format) throws Throwable {
4317 if (parameter instanceof byte[]) {
4318 byte[] encodedParameter = (byte[]) parameter;
4319 if (format == null) {
4320 algorithm.init(encodedParameter);
4321 } else {
4322 algorithm.init(encodedParameter, format);
4323 }
4324 } else if (parameter instanceof AlgorithmParameterSpec) {
4325 AlgorithmParameterSpec parameterSpec = (AlgorithmParameterSpec) parameter;
4326 algorithm.init(parameterSpec);
4327 } else {
4328 throw new Throwable();
4329 }
4330 }
4331
4332 /**
4333 * Mediante JCE, inicializa de forma específica un algoritmo criptográfico
4334 * de protección
4335 *
4336 * @param algorithm
4337 * Algoritmo criptográfico de protección
4338 * @param key
4339 * @param parameter
4340 * @param random
4341 * @param parameterType
4342 * @return
4343 * @throws Throwable
4344 */
4345 public static AlgorithmParameterSpec initiateForProtection_JCE(
4346 Cipher algorithm, int mode, Key key,
4347 AlgorithmParameterSpec parameter, SecureRandom random,
4348 Class parameterType) throws Throwable {
4349 AlgorithmParameterSpec result = null;
4350 if (parameter != null && random == null) {
4351 algorithm.init(mode, key, parameter);
4352 } else if (parameter != null && random != null) {
4353 algorithm.init(mode, key, parameter, random);
4354 } else if (parameter == null && random == null) {
4355 algorithm.init(mode, key);
4356 } else if (parameter == null && random != null) {
4357 algorithm.init(mode, key, random);
4358 }
4359 try {
4360 AlgorithmParameters algorithmParameters = algorithm.getParameters();
4361 if (parameter == null && algorithmParameters != null) {
4362 result = algorithmParameters.getParameterSpec(parameterType);
4363 }
4364 } catch (NullPointerException exception) {
4365 }
4366 return result;
4367 }
4368
4369 /**
4370 *
4371 * @param algorithm
4372 * @param key
4373 * @param parameter
4374 * @param random
4375 * @param parameterType
4376 * @return
4377 * @throws Throwable
4378 */
4379 public static AlgorithmParameterSpec initiateForProtection_JCE(
4380 Cipher algorithm, Key key, AlgorithmParameterSpec parameter,
4381 SecureRandom random, Class parameterType) throws Throwable {
4382 AlgorithmParameterSpec result = null;
4383 int mode = Cipher.DECRYPT_MODE;
4384 result = initiateForProtection_JCE(algorithm, mode, key, parameter,
4385 random, parameterType);
4386 return result;
4387 }
4388
4389 public static AlgorithmParameterSpec initiateForUnprotection_JCE(
4390 Cipher algorithm, Key key, AlgorithmParameterSpec parameter,
4391 SecureRandom random, Class parameterType) throws Throwable {
4392 AlgorithmParameterSpec result = null;
4393 int mode = Cipher.DECRYPT_MODE;
4394 result = initiateForProtection_JCE(algorithm, mode, key, parameter,
4395 random, parameterType);
4396 return result;
4397 }
4398
4399 public static AlgorithmParameterSpec initiateForWrapKey_JCE(
4400 Cipher algorithm, Key key, AlgorithmParameterSpec parameter,
4401 SecureRandom random, Class parameterType) throws Throwable {
4402 AlgorithmParameterSpec result = null;
4403 int mode = Cipher.WRAP_MODE;
4404 result = initiateForProtection_JCE(algorithm, mode, key, parameter,
4405 random, parameterType);
4406 return result;
4407 }
4408
4409 public static AlgorithmParameterSpec initiateForUnwrapKey_JCE(
4410 Cipher algorithm, Key key, AlgorithmParameterSpec parameter,
4411 SecureRandom random, Class parameterType) throws Throwable {
4412 AlgorithmParameterSpec result = null;
4413 int mode = Cipher.UNWRAP_MODE;
4414 result = initiateForProtection_JCE(algorithm, mode, key, parameter,
4415 random, parameterType);
4416 return result;
4417 }
4418
4419 /**
4420 * Mediante JCE, inicializa de forma específica un algoritmo generador de
4421 * claves simétricas
4422 *
4423 * @param algorithm
4424 * Algoritmo generador de claves simétricas
4425 * @param genParameter
4426 * Parámetro de inicialización para
4427 * {@link KeyGenerator#init(java.security.spec.AlgorithmParameterSpec)}
4428 * o
4429 * {@link KeyGenerator#init(java.security.spec.AlgorithmParameterSpec, java.security.SecureRandom)}
4430 * @param keySize
4431 * Parámetro de inicialización para
4432 * {@link KeyGenerator#init(int)} o
4433 * {@link KeyGenerator#init(int, java.security.SecureRandom)}
4434 * @param random
4435 * Parámetro de inicialización para
4436 * {@link KeyGenerator#init(int, java.security.SecureRandom)},
4437 * {@link KeyGenerator#init(java.security.SecureRandom)} o
4438 * {@link KeyGenerator#init(java.security.spec.AlgorithmParameterSpec, java.security.SecureRandom)}
4439 * @throws InvalidAlgorithmParameterException
4440 * Ocurre si no se ha podido realizar la operación
4441 * @see javax.crypto.KeyGenerator#init(int)
4442 * @see javax.crypto.KeyGenerator#init(int, java.security.SecureRandom)
4443 * @see javax.crypto.KeyGenerator#init(java.security.SecureRandom)
4444 * @see javax.crypto.KeyGenerator#init(java.security.spec.AlgorithmParameterSpec)
4445 * @see javax.crypto.KeyGenerator#init(java.security.spec.AlgorithmParameterSpec,
4446 * java.security.SecureRandom)
4447 * @see javax.crypto.KeyGenerator
4448 * @see #setInitiationInfo_JCE(javax.crypto.KeyGenerator, Map)
4449 */
4450 public static void initiate_JCE(javax.crypto.KeyGenerator algorithm,
4451 AlgorithmParameterSpec genParameter, int keySize,
4452 SecureRandom random) throws InvalidAlgorithmParameterException {
4453 if (genParameter != null && random == null) {
4454 algorithm.init(genParameter);
4455 } else if (genParameter != null && random != null) {
4456 algorithm.init(genParameter, random);
4457 } else if (genParameter == null && keySize > 0 && random == null) {
4458 algorithm.init(keySize);
4459 } else if (genParameter == null && keySize > 0 && random != null) {
4460 algorithm.init(keySize, random);
4461 } else if (genParameter == null && keySize <= 0 && random != null) {
4462 algorithm.init(random);
4463 }
4464 }
4465
4466 /**
4467 * Mediante JCE, inicializa de forma específica un algoritmo traductor de
4468 * claves asimétricas
4469 *
4470 * @param algorithm
4471 * Algoritmo traductor de claves asimétricas
4472 * @see KeyFactory
4473 * @see #setInitiationInfo_JCE(KeyFactory, Map)
4474 */
4475 public static void initiate_JCE(KeyFactory algorithm) {
4476 }
4477
4478 /**
4479 * Mediante JCE, inicializa de forma específica un algoritmo generador de
4480 * claves asimétricas
4481 *
4482 * @param algorithm
4483 * Algoritmo generador de claves asimétricas JCE
4484 * @param genParameter
4485 * Parámetro de inicialización para
4486 * {@link KeyPairGenerator#initialize(java.security.spec.AlgorithmParameterSpec)}
4487 * o
4488 * {@link KeyPairGenerator#initialize(java.security.spec.AlgorithmParameterSpec, java.security.SecureRandom)}
4489 * @param keySize
4490 * Parámetro de inicialización para
4491 * {@link KeyPairGenerator#initialize(int)} o
4492 * {@link KeyPairGenerator#initialize(int, java.security.SecureRandom)}
4493 * @param random
4494 * Parámetro de inicialización para
4495 * {@link KeyPairGenerator#initialize(int, java.security.SecureRandom)}
4496 * o
4497 * {@link KeyPairGenerator#initialize(java.security.spec.AlgorithmParameterSpec, java.security.SecureRandom)}
4498 * @throws InvalidAlgorithmParameterException
4499 * Ocurre si no se ha podido realizar la operación
4500 * @see KeyPairGenerator#initialize(int)
4501 * @see KeyPairGenerator#initialize(int, java.security.SecureRandom)
4502 * @see KeyPairGenerator#initialize(java.security.spec.AlgorithmParameterSpec)
4503 * @see KeyPairGenerator#initialize(java.security.spec.AlgorithmParameterSpec,
4504 * java.security.SecureRandom)
4505 * @see KeyPairGenerator
4506 * @see #setInitiationInfo_JCE(KeyPairGenerator, Map)
4507 */
4508 public static void initiate_JCE(KeyPairGenerator algorithm,
4509 AlgorithmParameterSpec genParameter, int keySize,
4510 SecureRandom random) throws InvalidAlgorithmParameterException {
4511 if (genParameter != null && random == null) {
4512 algorithm.initialize(genParameter);
4513 } else if (genParameter != null && random != null) {
4514 algorithm.initialize(genParameter, random);
4515 } else if (genParameter == null && random == null) {
4516 algorithm.initialize(keySize);
4517 } else if (genParameter == null && random != null) {
4518 algorithm.initialize(keySize, random);
4519 }
4520 }
4521
4522 /**
4523 * Mediante JCE, inicializa de forma específica un algoritmo criptográfico
4524 * de autentificación mediante sellos digitales
4525 *
4526 * @param algorithm
4527 * Algoritmo criptográfico de autentificación mediante sellos
4528 * digitales
4529 * @param symmetricKey
4530 * Parámetro de inicialización
4531 * @param parameter
4532 * Parámetro de inicialización
4533 * @throws InvalidKeyException
4534 * Ocurre si no se ha podido realizar la operación
4535 * @throws InvalidAlgorithmParameterException
4536 * Ocurre si no se ha podido realizar la operación
4537 */
4538 public static void initiate_JCE(Mac algorithm, SecretKey symmetricKey,
4539 AlgorithmParameterSpec parameter) throws InvalidKeyException,
4540 InvalidAlgorithmParameterException {
4541 if (parameter == null) {
4542 algorithm.init(symmetricKey);
4543 } else {
4544 algorithm.init(symmetricKey, parameter);
4545 }
4546 }
4547
4548 /**
4549 * Mediante JCE, inicializa de forma específica un algoritmo criptográfico
4550 * de autentificación mediante huellas digitales JCE
4551 *
4552 * @param algorithm
4553 * Algoritmo criptográfico de autentificación mediante huellas
4554 * digitales JCE
4555 * @see #setInitiationInfo_JCE(MessageDigest, Map)
4556 * @see MessageDigest
4557 */
4558 public static void initiate_JCE(MessageDigest algorithm) {
4559 }
4560
4561 /**
4562 * Mediante JCE, inicializa de forma específica un algoritmo traductor de
4563 * claves simétricas JCE
4564 *
4565 * @param algorithm
4566 * Algoritmo traductor de claves simétricas JCE
4567 * @see SecretKeyFactory
4568 * @see #setInitiationInfo_JCE(SecretKeyFactory, Map)
4569 */
4570 public static void initiate_JCE(SecretKeyFactory algorithm) {
4571 }
4572
4573 /**
4574 * Mediante JCE, inicializa de forma específica un algoritmo generador de
4575 * datos aleatorios JCE
4576 *
4577 * @param algorithm
4578 * Algoritmo generador de datos aleatorios JCE
4579 * @param seed
4580 * Parámetro de inicialización para
4581 * {@link SecureRandom#setSeed(byte[])}
4582 * @see #setInitiationInfo_JCE(SecureRandom, Map)
4583 */
4584 public static void initiate_JCE(SecureRandom algorithm, byte[] seed) {
4585 algorithm.setSeed(seed);
4586 }
4587
4588 /**
4589 * Mediante JCEF, inicializa de forma específica un algoritmo JCEF
4590 *
4591 * @param algorithm
4592 * Algoritmo JCEF
4593 * @param additionalParameter
4594 * Parámetro de inicialización
4595 * {@link Algorithm#setAdditionalParameter(AlgorithmParameterSpec)}
4596 * @see Algorithm#setAdditionalParameter(AlgorithmParameterSpec)
4597 * @see #setInitiationInfo_JCEF(Algorithm, Map)
4598 */
4599 public static void initiate_JCEF(Algorithm algorithm,
4600 AlgorithmParameterSpec additionalParameter) {
4601 algorithm.setAdditionalParameter(additionalParameter);
4602 }
4603
4604 /**
4605 * Mediante JCEF, inicializa de forma específica un algoritmo generador de
4606 * claves asimétricas JCEF
4607 *
4608 * @param algorithm
4609 * Algoritmo generador de claves asimétricas JCEF
4610 */
4611 public static void initiate_JCEF(AsymmetricKeyGenerator algorithm) {
4612 }
4613
4614 /**
4615 * Mediante JCEF, inicializa de forma específica un algoritmo traductor de
4616 * claves asimétricas
4617 *
4618 * @param algorithm
4619 * Algoritmo traductor de claves asimétricas
4620 * @see AsymmetricKeyTranslator
4621 * @see #setInitiationInfo_JCEF(AsymmetricKeyTranslator, Map)
4622 */
4623 public static void initiate_JCEF(AsymmetricKeyTranslator algorithm) {
4624 }
4625
4626 /**
4627 * Mediante JCEF, inicializa de forma específica un algoritmo criptográfico
4628 * de autentificación JCEF
4629 *
4630 * @param algorithm
4631 * Algoritmo criptográfico de autentificación JCEF
4632 */
4633 public static void initiate_JCEF(AuthenticationAlgorithm algorithm) {
4634 }
4635
4636 /**
4637 * Mediante JCEF, inicializa de forma específica un algoritmo criptográfico
4638 * JCEF
4639 *
4640 * @param algorithm
4641 * Algoritmo criptográfico JCEF
4642 * @param parameter
4643 * Parámetro de inicialización para
4644 * {@link CryptoAlgorithm#setParameter(AlgorithmParameterSpec)},
4645 * {@link CryptoAlgorithm#setParameter(byte[])} o
4646 * {@link CryptoAlgorithm#setParameter(byte[], String)}
4647 * @param format
4648 * Parámetro de inicialización para
4649 * {@link CryptoAlgorithm#setParameter(byte[], String)}
4650 * @throws Throwable
4651 * Ocurre si no se ha podido realizar la operación
4652 * @see CryptoAlgorithm#setParameter(AlgorithmParameterSpec)
4653 * @see CryptoAlgorithm#setParameter(byte[])
4654 * @see CryptoAlgorithm#setParameter(byte[], String)
4655 * @see CryptoAlgorithm
4656 * @see #setInitiationInfo_JCEF(CryptoAlgorithm, Map)
4657 */
4658 public static void initiate_JCEF(CryptoAlgorithm algorithm,
4659 Object parameter, String format) throws Throwable {
4660 if (parameter instanceof AlgorithmParameterSpec) {
4661 algorithm.setParameter((AlgorithmParameterSpec) parameter);
4662 } else if (parameter instanceof byte[]) {
4663 if (format == null) {
4664 algorithm.setParameter((byte[]) parameter);
4665 } else {
4666 algorithm.setParameter((byte[]) parameter, format);
4667 }
4668 } else {
4669 algorithm.setParameter((AlgorithmParameterSpec) null);
4670 }
4671 }
4672
4673 /**
4674 * Mediante JCEF, inicializa de forma específica un algoritmo criptográfico
4675 * de autentificación mediante sellos digitales basados en contraseñas
4676 *
4677 * @param algorithm
4678 * Algoritmo criptográfico de autentificación mediante sellos
4679 * digitales basados en contraseña
4680 * @param password
4681 * Parámetro de inicialización para
4682 * {@link DigitalPBESeal#setPassword(char[])}
4683 * @throws Throwable
4684 * Ocurre si no se ha podido realizar la operación
4685 */
4686 public static void initiate_JCEF(DigitalPBESeal algorithm, char[] password)
4687 throws Throwable {
4688 algorithm.setPassword(password);
4689 }
4690
4691 /**
4692 * Mediante JCEF, inicializa de forma específica un algoritmo criptográfico
4693 * de autentificación mediante sellos digitales
4694 *
4695 * @param algorithm
4696 * Algoritmo criptográfico de autentificación mediante sellos
4697 * digitales
4698 * @param symmetricKey
4699 * Parámetro de inicialización
4700 * @throws Throwable
4701 * Ocurre si no se ha podido realizar la operación
4702 */
4703 public static void initiate_JCEF(DigitalSeal algorithm, Object symmetricKey)
4704 throws Throwable {
4705 if (symmetricKey instanceof SecretKey) {
4706 algorithm.setSymmetricKey((SecretKey) symmetricKey);
4707 } else if (symmetricKey instanceof KeySpec) {
4708 algorithm.setSymmetricKey((KeySpec) symmetricKey);
4709 } else if (symmetricKey instanceof byte[]) {
4710 algorithm.setSymmetricKey((byte[]) symmetricKey);
4711 } else {
4712 algorithm.setSymmetricKey((SecretKey) null);
4713 }
4714 }
4715
4716 /**
4717 * Inicializa de forma específica un algoritmo criptográfico de
4718 * autentificación mediante huellas digitales JCEF
4719 *
4720 * @param algorithm
4721 * Algoritmo criptográfico de autentificación mediante huellas
4722 * digitales JCEF
4723 */
4724 public static void initiate_JCEF(FingerPrint algorithm) {
4725 }
4726
4727 /**
4728 * Mediante JCEF, inicializa de forma específica un algoritmo generador JCEF
4729 *
4730 * @param algorithm
4731 * Algoritmo generador JCEF
4732 * @param random
4733 * Parámetro de inicialización para
4734 * {@link Generator#setRandom(SecureRandom)}
4735 * @param genParameter
4736 * Parámetro de inicialización para
4737 * {@link Generator#setGenParameter(AlgorithmParameterSpec)}
4738 * @throws Throwable
4739 * Ocurre si no se ha podido realizar la operación
4740 * @see Generator#setRandom(SecureRandom)
4741 * @see Generator#setGenParameter(AlgorithmParameterSpec)
4742 * @see Generator
4743 * @see #setInitiationInfo_JCEF(Generator, Map)
4744 */
4745 public static void initiate_JCEF(Generator algorithm, SecureRandom random,
4746 AlgorithmParameterSpec genParameter) throws Throwable {
4747 algorithm.setRandom(random);
4748 algorithm.setGenParameter(genParameter);
4749 }
4750
4751 /**
4752 * Mediante JCEF, inicializa de forma específica un objeto JCEF
4753 *
4754 * @param object
4755 * Objeto JCEF
4756 */
4757 public static void initiate_JCEF(JCEFObject object) {
4758 }
4759
4760 /**
4761 * Mediante JCEF, inicializa de forma específica un proveedor JCEF
4762 *
4763 * @param provider
4764 * Proveedor JCEF
4765 */
4766 public static void initiate_JCEF(JCEFProvider provider) {
4767 }
4768
4769 /**
4770 * Mediante JCEF, inicializa de forma específica un algoritmo generador de
4771 * claves JCEF
4772 *
4773 * @param algorithm
4774 * Algoritmo generador de claves JCEF
4775 * @param keySize
4776 * Parámetro de inicialización para
4777 * {@link KeyGenerator#setKeySize(int)}
4778 * @throws Throwable
4779 * Ocurre si no se ha podido realizar la operación
4780 * @see KeyGenerator#setKeySize(int)
4781 * @see KeyGenerator
4782 * @see #setInitiationInfo_JCEF(KeyGenerator, Map)
4783 */
4784 public static void initiate_JCEF(KeyGenerator algorithm, int keySize)
4785 throws Throwable {
4786 algorithm.setKeySize(keySize);
4787 }
4788
4789 /**
4790 * Mediante JCEF, inicializa de forma específica un algoritmo traductor de
4791 * claves
4792 *
4793 * @param algorithm
4794 * Algoritmo traductor de claves
4795 * @see KeyTranslator
4796 * @see #setInitiationInfo_JCEF(KeyTranslator, Map)
4797 */
4798 public static void initiate_JCEF(KeyTranslator algorithm) {
4799 }
4800
4801 /**
4802 * Mediante JCEF, inicializa de forma específica un algoritmo generador de
4803 * parámetros JCEF
4804 *
4805 * @param algorithm
4806 * Algoritmo generador de parámetros JCEF
4807 * @param parameterSize
4808 * Parámetro de inicialización para
4809 * {@link ParameterGenerator#setParameterSize(int)}
4810 * @throws Throwable
4811 * Ocurre si no se ha podido realizar la operación
4812 * @see ParameterGenerator#setParameterSize(int)
4813 * @see ParameterGenerator
4814 * @see #setInitiationInfo_JCEF(ParameterGenerator, Map)
4815 */
4816 public static void initiate_JCEF(ParameterGenerator algorithm,
4817 int parameterSize) throws Throwable {
4818 algorithm.setParameterSize(parameterSize);
4819 }
4820
4821 /**
4822 * Mediante JCEF, inicializa de forma específica un algoritmo traductor de
4823 * parámetros JCEF
4824 *
4825 * @param algorithm
4826 * Algoritmo traductor de parámetros JCEF
4827 */
4828 public static void initiate_JCEF(ParameterTranslator algorithm) {
4829 }
4830
4831 /**
4832 * Mediante JCEF, inicializa de forma específica un algoritmo criptográfico
4833 * de protección
4834 *
4835 * @param algorithm
4836 * Algoritmo criptográfico de protección
4837 */
4838 public static void initiate_JCEF(Protection algorithm) {
4839 }
4840
4841 /**
4842 * Mediante JCEF, inicializa de forma específica un algoritmo generador de
4843 * datos aleatorios JCEF
4844 *
4845 * @param algorithm
4846 * Algoritmo generador de datos aleatorios JCEF
4847 * @param seed
4848 * Parámetro de inicialización para
4849 * {@link SecureRandomGenerator#setSeed(byte[])}
4850 * @see SecureRandomGenerator#setSeed(byte[])
4851 * @see SecureRandomGenerator
4852 * @see #setInitiationInfo_JCEF(SecureRandomGenerator, Map)
4853 */
4854 public static void initiate_JCEF(SecureRandomGenerator algorithm,
4855 byte[] seed) {
4856 algorithm.setSeed(seed);
4857 }
4858
4859 /**
4860 * Mediante JCEF, inicializa de forma específica un algoritmo generador de
4861 * claves simétricas JCEF
4862 *
4863 * @param algorithm
4864 * Algoritmo generador de claves simétricas JCEF
4865 * @see SymmetricKeyGenerator
4866 * @see #setInitiationInfo_JCEF(SymmetricKeyGenerator, Map)
4867 */
4868 public static void initiate_JCEF(SymmetricKeyGenerator algorithm) {
4869 }
4870
4871 /**
4872 * Mediante JCEF, inicializa de forma específica un algoritmo traductor de
4873 * claves simétricas JCEF
4874 *
4875 * @param algorithm
4876 * Algoritmo traductor de claves simétricas JCEF
4877 * @see SymmetricKeyTranslator
4878 * @see #setInitiationInfo_JCEF(SymmetricKeyTranslator, Map)
4879 */
4880 public static void initiate_JCEF(SymmetricKeyTranslator algorithm) {
4881 }
4882
4883 /**
4884 * Mediante JCEF, inicializa de forma específica un algoritmo traductor JCEF
4885 *
4886 * @param algorithm
4887 * Algoritmo traductor JCEF
4888 */
4889 public static void initiate_JCEF(Translator algorithm) {
4890 }
4891
4892 /**
4893 * Mediante JCE, inicializa de forma específica en modo generación un
4894 * algoritmo criptográfico de autentificación de sellos digitales
4895 *
4896 * @param algorithm
4897 * Algoritmo criptográfico de autentificación de sellos digitales
4898 */
4899 public static void initiateForGeneration_JCE(Mac algorithm) {
4900 }
4901
4902 /**
4903 * Mediante JCE, inicializa de forma específica en modo generación un
4904 * algoritmo criptográfico de autentificación mediante huellas digitales JCE
4905 *
4906 * @param algorithm
4907 * Algoritmo criptográfico de autentificación mediante huellas
4908 * digitales JCE
4909 * @see MessageDigest
4910 * @see #setInitiationInfoForGeneration_JCE(MessageDigest, Map)
4911 */
4912 public static void initiateForGeneration_JCE(MessageDigest algorithm) {
4913 }
4914
4915 /**
4916 * Mediante JCE, inicializa de forma específica en modo generación un
4917 * algoritmo criptográfico de autentificación mediante firmas digitales
4918 *
4919 * @param algorithm
4920 * Algoritmo criptográfico de autentificación mediante firmas
4921 * digitales
4922 * @param signingKey
4923 * Parámetro de inicialización
4924 * @param parameter
4925 * Parámetro de inicialización
4926 * @param random
4927 * Parámetro de inicialización
4928 * @param parameterType
4929 * Parámetro de inicialización
4930 * @return Parámetro generado automáticamente si fuera preciso
4931 * @throws Throwable
4932 * Ocurre si no se ha podido realizar la operación
4933 */
4934 public static AlgorithmParameterSpec initiateForGeneration_JCE(
4935 Signature algorithm, PrivateKey signingKey,
4936 AlgorithmParameterSpec parameter, SecureRandom random,
4937 Class parameterType) throws Throwable {
4938 AlgorithmParameterSpec result = null;
4939 try {
4940 if (parameter != null) {
4941 algorithm.setParameter(parameter);
4942 }
4943 } catch (Throwable throwable) {
4944 throw new Throwable("This algorithm don't use parameters");
4945 }
4946 if (random == null) {
4947 algorithm.initSign(signingKey);
4948 } else {
4949 algorithm.initSign(signingKey, random);
4950 }
4951 AlgorithmParameters algorithmParameters = algorithm.getParameters();
4952 if (parameter == null && algorithmParameters != null) {
4953 result = algorithmParameters.getParameterSpec(parameterType);
4954 }
4955 return result;
4956 }
4957
4958 public static void initiateForGeneration_JCEF(DigitalPBESeal algorithm) {
4959 }
4960
4961 public static void initiateForGeneration_JCEF(DigitalSeal algorithm) {
4962 }
4963
4964 public static void initiateForGeneration_JCEF(DigitalSignature algorithm,
4965 Object signingKey) throws Throwable {
4966 if (signingKey instanceof PrivateKey) {
4967 algorithm.setSigningKey((PrivateKey) signingKey);
4968 } else if (signingKey instanceof KeySpec) {
4969 algorithm.setSigningKey((KeySpec) signingKey);
4970 } else {
4971 algorithm.setSigningKey((PrivateKey) null);
4972 }
4973 }
4974
4975 /**
4976 * Inicializa de forma específica en modo generación un algoritmo
4977 * criptográfico de autentificación mediante huellas digitales JCEF
4978 *
4979 * @param algorithm
4980 * Algoritmo criptográfico de autentificación mediante huellas
4981 * digitales JCEF
4982 * @see #setInitiationInfoForGeneration_JCEF(FingerPrint, Map)
4983 * @see FingerPrint
4984 */
4985 public static void initiateForGeneration_JCEF(FingerPrint algorithm) {
4986 }
4987
4988 public static void initiateForVerification_JCE(Mac algorithm) {
4989 }
4990
4991 /**
4992 * Inicializa de forma específica en modo verificación un algoritmo
4993 * criptográfico de autentificación mediante huellas digitales JCE
4994 *
4995 * @param algorithm
4996 * Algoritmo criptográfico de autentificación mediante huellas
4997 * digitales JCE
4998 * @see MessageDigest
4999 * @see #setInitiationInfoForVerification_JCE(MessageDigest, Map)
5000 */
5001 public static void initiateForVerification_JCE(MessageDigest algorithm) {
5002 }
5003
5004 public static void initiateForVerification_JCE(Signature algorithm,
5005 PublicKey verifyKey, AlgorithmParameterSpec parameter)
5006 throws Throwable {
5007 try {
5008 if (parameter != null) {
5009 algorithm.setParameter(parameter);
5010 }
5011 } catch (Throwable throwable) {
5012 throw new Throwable("This algorithm don't use parameters");
5013 }
5014 algorithm.initVerify(verifyKey);
5015 }
5016
5017 public static void initiateForVerification_JCEF(DigitalPBESeal algorithm) {
5018 }
5019
5020 public static void initiateForVerification_JCEF(DigitalSeal algorithm) {
5021 }
5022
5023 public static void initiateForVerification_JCEF(DigitalSignature algorithm,
5024 Object verifyKey) throws Throwable {
5025 if (verifyKey instanceof PublicKey) {
5026 algorithm.setVerifyKey((PublicKey) verifyKey);
5027 } else if (verifyKey instanceof KeySpec) {
5028 algorithm.setVerifyKey((KeySpec) verifyKey);
5029 } else {
5030 algorithm.setVerifyKey((PublicKey) null);
5031 }
5032 }
5033
5034 /**
5035 * Inicializa de forma específica en modo verificación un algoritmo
5036 * criptográfico de autentificación mediante huellas digitales JCEF
5037 *
5038 * @param algorithm
5039 * Algoritmo criptográfico de autentificación mediante huellas
5040 * digitales JCEF
5041 * @see #setInitiationInfoForVerification_JCEF(FingerPrint, Map)
5042 * @see FingerPrint
5043 */
5044 public static void initiateForVerification_JCEF(FingerPrint algorithm) {
5045 }
5046
5047 /**
5048 * Define los parámetros de inicialización de un algoritmo generador de
5049 * parámetros JCE
5050 *
5051 * @param algorithm
5052 * Algoritmo generador de parámetros JCE
5053 * @param parameters
5054 * Parámetros de inicialización
5055 * @throws InvalidAlgorithmParameterException
5056 * @see #initiate_JCE(AlgorithmParameterGenerator, AlgorithmParameterSpec,
5057 * int, SecureRandom)
5058 * @see AlgorithmParameterGenerator
5059 * @see #setInitiationInfo_JCEF(ParameterGenerator, Map)
5060 */
5061 public static void setInitiationInfo_JCE(
5062 AlgorithmParameterGenerator algorithm, Map parameters)
5063 throws InvalidAlgorithmParameterException {
5064 AlgorithmParameterSpec genParameter = (AlgorithmParameterSpec) parameters
5065 .get("genParameter");
5066 int parameterSize = ((Integer) parameters.get("parameterSize"))
5067 .intValue();
5068 SecureRandom random = (SecureRandom) parameters.get("random");
5069 initiate_JCE(algorithm, genParameter, parameterSize, random);
5070 }
5071
5072 /**
5073 * Define los parámetros de inicialización de un algoritmo traductor de
5074 * parámetros JCE
5075 *
5076 * @param algorithm
5077 * Algoritmo traductor de parámetros JCE
5078 * @param parameters
5079 * Parámetros de inicialización
5080 * @throws Throwable
5081 * @see #initiate_JCE(AlgorithmParameters, boolean, boolean,
5082 * AlgorithmParameterSpec, byte[], String)
5083 * @see AlgorithmParameters
5084 * @see #setInitiationInfo_JCEF(ParameterTranslator, Map)
5085 */
5086 public static void setInitiationInfo_JCE(AlgorithmParameters algorithm,
5087 Map parameters) throws Throwable {
5088 Object parameter = parameters.get("parameter");
5089 String format = (String) parameters.get("format");
5090 initiate_JCE(algorithm, parameter, format);
5091 }
5092
5093 /**
5094 * Define la inicialización de un algoritmo generador de claves simétricas
5095 * JCE
5096 *
5097 * @throws InvalidAlgorithmParameterException
5098 * Ocurre si no se ha podido realizar la operación
5099 * @see #initiate(javax.crypto.KeyGenerator, AlgorithmParameterSpec, int,
5100 * SecureRandom)
5101 * @see #setInitiationInfo_JCEF(SymmetricKeyGenerator, Map)
5102 */
5103 public static void setInitiationInfo_JCE(
5104 javax.crypto.KeyGenerator algorithm, Map parameters)
5105 throws InvalidAlgorithmParameterException {
5106 AlgorithmParameterSpec genParameter = (AlgorithmParameterSpec) parameters
5107 .get("genParameter");
5108 int keySize = ((Integer) parameters.get("keySize")).intValue();
5109 SecureRandom random = (SecureRandom) parameters.get("random");
5110 initiate_JCE(algorithm, genParameter, keySize, random);
5111 }
5112
5113 /**
5114 * Define los parámetros de inicialización de un algoritmo traductor de
5115 * claves asimétricas JCE
5116 *
5117 * @param algorithm
5118 * Algoritmo traductor de claves asimétricas JCE
5119 * @param parameters
5120 * Parámetros de inicialización
5121 * @see #initiate_JCE(KeyFactory)
5122 * @see KeyFactory
5123 * @see #setInitiationInfo_JCEF(AsymmetricKeyTranslator, Map)
5124 */
5125 public static void setInitiationInfo_JCE(KeyFactory algorithm,
5126 Map parameters) {
5127 initiate_JCE(algorithm);
5128 }
5129
5130 /**
5131 * Define la inicialización de un algoritmo generador de claves asimétricas
5132 * JCE
5133 *
5134 * @param algorithm
5135 * Algoritmo generador de claves asimétricas JCE
5136 * @param parameters
5137 * Parámetros de inicialización
5138 * @throws Throwable
5139 * Ocurre si no se ha podido realizar la operación
5140 * @see #initiate_JCE(KeyPairGenerator, AlgorithmParameterSpec, int,
5141 * SecureRandom)
5142 * @see KeyPairGenerator
5143 * @see #setInitiationInfo_JCEF(AsymmetricKeyGenerator, Map)
5144 */
5145 public static void setInitiationInfo_JCE(KeyPairGenerator algorithm,
5146 Map parameters) throws Throwable {
5147 AlgorithmParameterSpec genParameter = (AlgorithmParameterSpec) parameters
5148 .get("genParameter");
5149 int keySize = ((Integer) parameters.get("keySize")).intValue();
5150 SecureRandom random = (SecureRandom) parameters.get("random");
5151 initiate_JCE(algorithm, genParameter, keySize, random);
5152 }
5153
5154 /**
5155 * Mediante JCE, define los parámetros de inicialización de un algoritmo
5156 * criptográfico de autentificación mediante sellos digitales
5157 *
5158 * @param algorithm
5159 * Algoritmo criptográfico de autentificación mediante sellos
5160 * digitales
5161 * @param parameters
5162 * Parámetros de inicialización
5163 * @throws InvalidAlgorithmParameterException
5164 * Ocurre si no se ha podido realizar la operación
5165 * @throws InvalidKeyException
5166 * Ocurre si no se ha podido realizar la operación
5167 */
5168 public static void setInitiationInfo_JCE(Mac algorithm, Map parameters)
5169 throws InvalidKeyException, InvalidAlgorithmParameterException {
5170 SecretKey symmetricKey = (SecretKey) parameters.get("symmetricKey");
5171 AlgorithmParameterSpec parameter = (AlgorithmParameterSpec) parameters
5172 .get("parameter");
5173 initiate_JCE(algorithm, symmetricKey, parameter);
5174 }
5175
5176 /**
5177 * Define los parámetros de inicialización de un algoritmo criptográfico de
5178 * autentificación mediante huellas digitales JCE
5179 *
5180 * @param algorithm
5181 * Algoritmo criptográfico de autentificación mediante huellas
5182 * digitales JCE
5183 * @param parameters
5184 * Parámetros de inicialización
5185 * @see #initiate_JCE(MessageDigest)
5186 * @see MessageDigest
5187 */
5188 public static void setInitiationInfo_JCE(MessageDigest algorithm,
5189 Map parameters) {
5190 initiate_JCE(algorithm);
5191 }
5192
5193 /**
5194 * Define los parámetros de inicialización de un algoritmo traductor de
5195 * claves simétricas JCE
5196 *
5197 * @param algorithm
5198 * Algoritmo traductor de claves simétricas JCE
5199 * @param parameters
5200 * Parámetros de inicialización
5201 * @see #initiate_JCE(SecretKeyFactory)
5202 * @see SecretKeyFactory
5203 * @see #setInitiationInfo_JCEF(SymmetricKeyTranslator, Map)
5204 */
5205 public static void setInitiationInfo_JCE(SecretKeyFactory algorithm,
5206 Map parameters) {
5207 initiate_JCE(algorithm);
5208 }
5209
5210 /**
5211 * Define los parámetros de inicialización de un algoritmo generador de
5212 * datos aleatorios JCE
5213 *
5214 * @param algorithm
5215 * Algoritmo generador de datos aleatorios JCE
5216 * @param parameters
5217 * Parámetros de inicialización
5218 * @see #initiate_JCE(SecureRandom, byte[])
5219 * @see SecureRandom
5220 * @see #setInitiationInfo_JCEF(SecureRandomGenerator, Map)
5221 */
5222 public static void setInitiationInfo_JCE(SecureRandom algorithm,
5223 Map parameters) {
5224 byte[] seed = (byte[]) parameters.get("seed");
5225 initiate_JCE(algorithm, seed);
5226 }
5227
5228 /**
5229 *
5230 * @param algorithm
5231 * @param parameters
5232 * @throws Throwable
5233 */
5234 public static void setInitiationInfo_JCE(Signature algorithm, Map parameters)
5235 throws Throwable {
5236 setInitiationInfoForGeneration_JCE(algorithm, parameters);
5237 setInitiationInfoForVerification_JCE(algorithm, parameters);
5238 }
5239
5240 /**
5241 * Define la inicialización de un algoritmo JCEF
5242 *
5243 * @param algorithm
5244 * Algoritmo JCEF
5245 * @param parameters
5246 * Parámetros de inicialización
5247 * @see #initiate_JCEF(Algorithm, AlgorithmParameterSpec)
5248 * @see Algorithm
5249 * @see #setInitiationInfo_JCEF(JCEFObject, Map)
5250 * @see #setInitiationInfo_JCEF(Generator, Map)
5251 * @see #setInitiationInfo_JCEF(Translator, Map)
5252 * @see #setInitiationInfo_JCEF(CryptoAlgorithm, Map)
5253 */
5254 public static void setInitiationInfo_JCEF(Algorithm algorithm,
5255 Map parameters) {
5256 setInitiationInfo_JCEF((JCEFObject) algorithm, parameters);
5257 AlgorithmParameterSpec additionalParameter = null;
5258 additionalParameter = (AlgorithmParameterSpec) parameters
5259 .get("additionalParameter");
5260 initiate_JCEF(algorithm, additionalParameter);
5261 }
5262
5263 /**
5264 * Define la inicialización de un algoritmo generador de claves asimétricas
5265 * JCEF
5266 *
5267 * @param algorithm
5268 * Algoritmo generador de claves asimétricas JCEF
5269 * @param parameters
5270 * Parámetros de inicialización
5271 * @throws Throwable
5272 * Ocurre si no se ha podido realizar la operación
5273 * @see #initiate_JCEF(AsymmetricKeyGenerator)
5274 * @see AsymmetricKeyGenerator
5275 * @see #setInitiationInfo(KeyGenerator, Map)
5276 */
5277 public static void setInitiationInfo_JCEF(AsymmetricKeyGenerator algorithm,
5278 Map parameters) throws Throwable {
5279 setInitiationInfo_JCEF((KeyGenerator) algorithm, parameters);
5280 initiate_JCEF(algorithm);
5281 }
5282
5283 /**
5284 * Define los parámetros de inicialización de un algoritmo traductor de
5285 * claves asimétricas JCEF
5286 *
5287 * @param algorithm
5288 * Algoritmo traductor de claves asimétricas JCEF
5289 * @param parameters
5290 * Parámetros de inicialización
5291 * @throws Throwable
5292 * Ocurre si no se ha podido realizar la operación
5293 * @see #initiate_JCEF(AsymmetricKeyTranslator)
5294 * @see AsymmetricKeyTranslator
5295 * @see #setInitiationInfo_JCEF(KeyTranslator, Map)
5296 * @see #setInitiationInfo_JCE(KeyFactory, Map)
5297 */
5298 public static void setInitiationInfo_JCEF(
5299 AsymmetricKeyTranslator algorithm, Map parameters) throws Throwable {
5300 setInitiationInfo_JCEF((KeyTranslator) algorithm, parameters);
5301 initiate_JCEF(algorithm);
5302 }
5303
5304 /**
5305 * Inicializa un algoritmo criptográfico de protección asimétrica para su
5306 * uso
5307 *
5308 * @param algorithm
5309 * Algoritmo criptográfico de protección asimétrica
5310 * @param parameters
5311 * Parámetros de inicialización
5312 * @throws Throwable
5313 * Ocurre si no se ha podido realizar la operación
5314 * @see AsymmetricProtection
5315 * @see #setInitiationInfo_JCEFForProtection(AsymmetricProtection, Map)
5316 * @see #setInitiationInfo_JCEFForUnprotection(AsymmetricProtection, Map)
5317 */
5318 public static void setInitiationInfo_JCEF(AsymmetricProtection algorithm,
5319 Map parameters) throws Throwable {
5320 setInitiationInfo_JCEFForProtection(algorithm, parameters);
5321 setInitiationInfo_JCEFForUnprotection(algorithm, parameters);
5322 }
5323
5324 /**
5325 * Define los parámetros de inicialización de un algoritmo criptográfico de
5326 * autentificación JCEF
5327 *
5328 * @param algorithm
5329 * Algoritmo criptográfico de autentificación JCEF
5330 * @param parameters
5331 * Parámetros de inicialización
5332 * @throws Throwable
5333 * Ocurre si no se ha podido realizar la operación
5334 * @see #initiate_JCEF(AuthenticationAlgorithm)
5335 * @see AuthenticationAlgorithm
5336 * @see #setInitiationInfo_JCEF(CryptoAlgorithm, Map)
5337 * @see #setInitiationInfo_JCEF(FingerPrint, Map)
5338 * @see #setInitiationInfo_JCEF(DigitalSeal, Map)
5339 * @see #setInitiationInfo_JCEF(DigitalSignature, Map)
5340 */
5341 public static void setInitiationInfo_JCEF(
5342 AuthenticationAlgorithm algorithm, Map parameters) throws Throwable {
5343 setInitiationInfo_JCEF((CryptoAlgorithm) algorithm, parameters);
5344 initiate_JCEF(algorithm);
5345 }
5346
5347 /**
5348 * Inicializa un algoritmo criptográfico de protección simétrica de bloques
5349 *
5350 * @param algorithm
5351 * Algoritmo criptográfico de protección simétrica de bloques
5352 * @param parameters
5353 * Parámetros de inicialización
5354 * @throws Throwable
5355 * Ocurre si no se ha podido realizar la operación
5356 * @see BlockSymmetricProtection
5357 * @see #setInitiationInfo_JCEF(SymmetricProtection, Map)
5358 */
5359 public static void setInitiationInfo_JCEF(
5360 BlockSymmetricProtection algorithm, Map parameters)
5361 throws Throwable {
5362 setInitiationInfo_JCEF((SymmetricProtection) algorithm, parameters);
5363 }
5364
5365 /**
5366 * Define los parámetros de inicialización de un algoritmo criptográfico
5367 * JCEF
5368 *
5369 * @param algorithm
5370 * Algoritmo criptográfico JCEF
5371 * @param parameters
5372 * Parámetros de inicialización
5373 * @throws Throwable
5374 * Ocurre si no se ha podido realizar la operación
5375 * @see #initiate_JCEF(CryptoAlgorithm, Object, String)
5376 * @see CryptoAlgorithm
5377 * @see #setInitiationInfo_JCEF(Algorithm, Map)
5378 * @see #setInitiationInfo_JCEF(AuthenticationAlgorithm, Map)
5379 * @see #setInitiationInfo_JCEF(Protection, Map)
5380 */
5381 public static void setInitiationInfo_JCEF(CryptoAlgorithm algorithm,
5382 Map parameters) throws Throwable {
5383 setInitiationInfo_JCEF((Algorithm) algorithm, parameters);
5384 Object parameter = parameters.get("parameter");
5385 String format = (String) parameters.get("format");
5386 initiate_JCEF(algorithm, parameter, format);
5387 }
5388
5389 /**
5390 * Inicializa un algoritmo criptográfico de autentificación mediante sellos
5391 * digitales basados en contraseña
5392 *
5393 * @param algorithm
5394 * Algoritmo criptográfico de autentificación mediante sellos
5395 * digitales basados en contraseña
5396 * @param parameters
5397 * Parámetros de inicialización
5398 * @throws Throwable
5399 * Ocurre si no se ha podido realizar la operación
5400 * @see DigitalPBESeal#setPassword(char[])
5401 * @see DigitalPBESeal
5402 * @see #setInitiationInfo_JCEF(DigitalSeal, Map)
5403 */
5404 public static void setInitiationInfo_JCEF(DigitalPBESeal algorithm,
5405 Map parameters) throws Throwable {
5406 setInitiationInfo_JCEF((DigitalSeal) algorithm, parameters);
5407 char[] password = (char[]) parameters.get("password");
5408 initiate_JCEF(algorithm, password);
5409 }
5410
5411 /**
5412 * Inicializa un algoritmo criptográfico de autentificación mediante sellos
5413 * digitales
5414 *
5415 * @param algorithm
5416 * Algoritmo criptográfico de autentificación mediante sellos
5417 * digitales
5418 * @param parameters
5419 * Parámetros de inicialización
5420 * @throws Throwable
5421 * Ocurre si no se ha podido realizar la operación
5422 * @see DigitalSeal#setSymmetricKey(SecretKey)
5423 * @see DigitalSeal#setSymmetricKey(KeySpec)
5424 * @see DigitalSeal#setSymmetricKey(byte[])
5425 * @see DigitalSeal
5426 * @see #setInitiationInfo_JCEF(AuthenticationAlgorithm, Map)
5427 * @see #setInitiationInfo_JCEF(DigitalPBESeal, Map)
5428 */
5429 public static void setInitiationInfo_JCEF(DigitalSeal algorithm,
5430 Map parameters) throws Throwable {
5431 setInitiationInfo_JCEF((AuthenticationAlgorithm) algorithm, parameters);
5432 Object symmetricKey = parameters.get("symmetricKey");
5433 initiate_JCEF(algorithm, symmetricKey);
5434 }
5435
5436 /**
5437 * Inicializa un algoritmo criptográfico de autentificación mediante firmas
5438 * digitales
5439 *
5440 * @param algorithm
5441 * Algoritmo criptográfico de autentificación mediante firmas
5442 * digitales
5443 * @param parameters
5444 * Parámetros de inicialización
5445 * @throws Throwable
5446 * Ocurre si no se ha podido realizar la operación
5447 * @see DigitalSignature
5448 * @see #setInitiationInfo_JCEF(AuthenticationAlgorithm, Map)
5449 * @see #setInitiationInfo_JCEFForGeneration(DigitalSignature, Map)
5450 * @see #setInitiationInfo_JCEFForVerification(DigitalSignature, Map)
5451 */
5452 public static void setInitiationInfo_JCEF(DigitalSignature algorithm,
5453 Map parameters) throws Throwable {
5454 setInitiationInfoForGeneration_JCEF(algorithm, parameters);
5455 setInitiationInfoForVerification_JCEF(algorithm, parameters);
5456 }
5457
5458 /**
5459 * Define los parámetros de inicialización de un algoritmo criptográfico de
5460 * autentificación mediante huellas digitales JCEF
5461 *
5462 * @param algorithm
5463 * Algoritmo criptográfico de autentificación mediante huellas
5464 * digitales JCEF
5465 * @param parameters
5466 * Parámetros de inicialización
5467 * @throws Throwable
5468 * Ocurre si no se ha podido realizar la operación
5469 * @see FingerPrint
5470 * @see #setInitiationInfo_JCEF(AuthenticationAlgorithm, Map)
5471 * @see #setInitiationInfo_JCE(MessageDigest, Map)
5472 */
5473 public static void setInitiationInfo_JCEF(FingerPrint algorithm,
5474 Map parameters) throws Throwable {
5475 setInitiationInfo_JCEF((AuthenticationAlgorithm) algorithm, parameters);
5476 initiate_JCEF(algorithm);
5477 }
5478
5479 /**
5480 * Define la inicialización de un algoritmo generador JCEF
5481 *
5482 * @param algorithm
5483 * Algoritmo generador JCEF
5484 * @param parameters
5485 * Parámetros de inicialización
5486 * @throws Throwable
5487 * Ocurre si no se ha podido realizar la operación
5488 * @see #initiate_JCEF(Generator, SecureRandom, AlgorithmParameterSpec)
5489 * @see Generator
5490 * @see #setInitiationInfo_JCEF(Algorithm, Map)
5491 * @see #setInitiationInfo_JCEF(KeyGenerator, Map)
5492 * @see #setInitiationInfo_JCEF(ParameterGenerator, Map)
5493 * @see #setInitiationInfo_JCEF(SecureRandomGenerator, Map)
5494 */
5495 public static void setInitiationInfo_JCEF(Generator algorithm,
5496 Map parameters) throws Throwable {
5497 setInitiationInfo_JCEF((Algorithm) algorithm, parameters);
5498 SecureRandom random = (SecureRandom) parameters.get("random");
5499 AlgorithmParameterSpec genParameter = null;
5500 genParameter = (AlgorithmParameterSpec) parameters.get("genParameter");
5501 initiate_JCEF(algorithm, random, genParameter);
5502 }
5503
5504 /**
5505 * Define la inicialización de un objeto JCEF
5506 *
5507 * @param object
5508 * Objeto JCEF
5509 * @param parameters
5510 * Parámetros de inicialización
5511 * @see #initiate_JCEF(JCEFObject)
5512 * @see JCEFObject
5513 * @see #setInitiationInfo_JCEF(Algorithm, Map)
5514 * @see #setInitiationInfo_JCEF(JCEFProvider, Map)
5515 */
5516 public static void setInitiationInfo_JCEF(JCEFObject object, Map parameters) {
5517 initiate_JCEF(object);
5518 }
5519
5520 /**
5521 * Define la inicialización de un proveedor JCEF
5522 *
5523 * @param provider
5524 * Proveedor JCEF
5525 * @param parameters
5526 * Parámetros de inicialización
5527 * @see #initiate_JCEF(JCEFProvider)
5528 * @see JCEFProvider
5529 * @see #setInitiationInfo_JCEF(JCEFObject, Map)
5530 */
5531 public static void setInitiationInfo_JCEF(JCEFProvider provider,
5532 Map parameters) {
5533 setInitiationInfo_JCEF((JCEFObject) provider, parameters);
5534 initiate_JCEF(provider);
5535 }
5536
5537 /**
5538 * Define la inicialización de un algoritmo generador de claves JCEF
5539 *
5540 * @param algorithm
5541 * Algoritmo generador de claves JCEF
5542 * @param parameters
5543 * Parámetros de inicialización
5544 * @throws Throwable
5545 * Ocurre si no se ha podido realizar la operación
5546 * @see #initiate_JCEF(KeyGenerator, int)
5547 * @see KeyGenerator
5548 * @see #setInitiationInfo_JCEF(Generator, Map)
5549 * @see #setInitiationInfo_JCEF(AsymmetricKeyGenerator, Map)
5550 * @see #setInitiationInfo_JCEF(SymmetricKeyGenerator, Map)
5551 */
5552 public static void setInitiationInfo_JCEF(KeyGenerator algorithm,
5553 Map parameters) throws Throwable {
5554 setInitiationInfo_JCEF((Generator) algorithm, parameters);
5555 int keySize = ((Integer) parameters.get("keySize")).intValue();
5556 initiate_JCEF(algorithm, keySize);
5557 }
5558
5559 /**
5560 * Define los parámetros de inicialización de un traductor de claves JCEF
5561 *
5562 * @param algorithm
5563 * Algoritmo traductor de claves JCEF
5564 * @param parameters
5565 * Parámetros de inicialización
5566 * @throws Throwable
5567 * Ocurre si no se ha podido realizar la operación
5568 * @see #initiate_JCEF(KeyTranslator)
5569 * @see KeyTranslator
5570 * @see #setInitiationInfo_JCEF(Translator, Map)
5571 * @see #setInitiationInfo_JCEF(AsymmetricKeyTranslator, Map)
5572 * @see #setInitiationInfo_JCEF(SymmetricKeyTranslator, Map)
5573 */
5574 public static void setInitiationInfo_JCEF(KeyTranslator algorithm,
5575 Map parameters) throws Throwable {
5576 setInitiationInfo_JCEF((Translator) algorithm, parameters);
5577 initiate_JCEF(algorithm);
5578 }
5579
5580 /**
5581 * Define la inicialización de un algoritmo generador de parámetros JCEF
5582 *
5583 * @param algorithm
5584 * Algoritmo generador de parámetros JCEF
5585 * @param parameters
5586 * Parámetros de inicialización
5587 * @throws Throwable
5588 * Ocurre si no se ha podido realizar la operación
5589 * @see #initiate_JCEF(ParameterGenerator, int)
5590 * @see ParameterGenerator
5591 * @see #setInitiationInfo_JCEF(Generator, Map)
5592 * @see #setInitiationInfo_JCE(AlgorithmParameterGenerator, Map)
5593 */
5594 public static void setInitiationInfo_JCEF(ParameterGenerator algorithm,
5595 Map parameters) throws Throwable {
5596 setInitiationInfo_JCEF((Generator) algorithm, parameters);
5597 int parameterSize = ((Integer) parameters.get("parameterSize"))
5598 .intValue();
5599 initiate_JCEF(algorithm, parameterSize);
5600 }
5601
5602 /**
5603 * Define los parámetros de inicialización de un algoritmo traductor de
5604 * parámetros JCEF
5605 *
5606 * @param algorithm
5607 * Algoritmo traductor de parámetros JCEF
5608 * @param parameters
5609 * Parámetros de inicialización
5610 * @throws Throwable
5611 * Ocurre si no se ha podido realizar la operación
5612 * @see #initiate_JCEF(ParameterTranslator)
5613 * @see ParameterTranslator
5614 * @see #setInitiationInfo_JCEF(Translator, Map)
5615 * @see #setInitiationInfo_JCE(AlgorithmParameters, Map)
5616 */
5617 public static void setInitiationInfo_JCEF(ParameterTranslator algorithm,
5618 Map parameters) throws Throwable {
5619 setInitiationInfo_JCEF((Translator) algorithm, parameters);
5620 initiate_JCEF(algorithm);
5621 }
5622
5623 /**
5624 * Inicializa un algoritmo criptográfico de protección basada en contraseña
5625 *
5626 * @param algorithm
5627 * Algoritmo criptográfico de protección basada en contraseña
5628 * @param parameters
5629 * Parámetros de inicialización
5630 * @throws Throwable
5631 * Ocurre si no se ha podido realizar la operación
5632 * @see PBEProtection#setPassword(char[])
5633 * @see PBEProtection
5634 * @see #getInitiationInfo_JCEF(SymmetricProtection)
5635 */
5636 public static void setInitiationInfo_JCEF(PBEProtection algorithm,
5637 Map parameters) throws Throwable {
5638 setInitiationInfo_JCEF((SymmetricProtection) algorithm, parameters);
5639 char[] password = (char[]) parameters.get("password");
5640 algorithm.setPassword(password);
5641 }
5642
5643 /**
5644 * Inicializa un algoritmo criptográfico de protección para su uso
5645 *
5646 * @param algorithm
5647 * Algoritmo criptográfico de protección
5648 * @param parameters
5649 * Parámetros de inicialización
5650 * @throws Throwable
5651 * Ocurre si no se ha podido realizar la operación
5652 * @see Protection
5653 * @see #setInitiationInfo_JCEF(CryptoAlgorithm, Map)
5654 * @see #setInitiationInfo_JCEF(AsymmetricProtection, Map)
5655 * @see #setInitiationInfo_JCEF(SymmetricProtection, Map)
5656 */
5657 public static void setInitiationInfo_JCEF(Protection algorithm,
5658 Map parameters) throws Throwable {
5659 setInitiationInfo_JCEF((CryptoAlgorithm) algorithm, parameters);
5660 initiate_JCEF(algorithm);
5661 }
5662
5663 /**
5664 * Define los parámetros de inicialización de un algoritmo generador de
5665 * datos aleatorios JCEF
5666 *
5667 * @param algorithm
5668 * Algoritmo generador de datos aleatorios JCEF
5669 * @param parameters
5670 * Parámetros de inicialización
5671 * @throws Throwable
5672 * Ocurre si no se ha podido realizar la operación
5673 * @see #initiate_JCEF(SecureRandomGenerator, byte[])
5674 * @see SecureRandomGenerator
5675 * @see #setInitiationInfo_JCEF(Generator, Map)
5676 * @see #setInitiationInfo_JCE(SecureRandom, Map)
5677 */
5678 public static void setInitiationInfo_JCEF(SecureRandomGenerator algorithm,
5679 Map parameters) throws Throwable {
5680 setInitiationInfo_JCEF((Generator) algorithm, parameters);
5681 byte[] seed = (byte[]) parameters.get("seed");
5682 initiate_JCEF(algorithm, seed);
5683 }
5684
5685 /**
5686 * Inicializa un algoritmo criptográfico de protección simétrica de flujo
5687 *
5688 * @param algorithm
5689 * Algoritmo criptográfico de protección simétrica de flujo
5690 * @param parameters
5691 * Parámetros de inicialización
5692 * @throws Throwable
5693 * Ocurre si no se ha podido realizar la operación
5694 */
5695 public static void setInitiationInfo_JCEF(
5696 StreamSymmetricProtection algorithm, Map parameters)
5697 throws Throwable {
5698 setInitiationInfo_JCEF((SymmetricProtection) algorithm, parameters);
5699 }
5700
5701 /**
5702 * Define la inicialización de un algoritmo generador de claves simétricas
5703 * JCEF
5704 *
5705 * @param algorithm
5706 * Algoritmo generador de claves simétricas JCEF
5707 * @param parameters
5708 * Parámetros de inicialización
5709 * @throws Throwable
5710 * Ocurre si no se ha podido realizar la operación
5711 * @see SymmetricKeyGenerator
5712 * @see #setInitiationInfo_JCEF(KeyGenerator, Map)
5713 * @see #setInitiationInfo_JCE(javax.crypto.KeyGenerator, Map)
5714 */
5715 public static void setInitiationInfo_JCEF(SymmetricKeyGenerator algorithm,
5716 Map parameters) throws Throwable {
5717 setInitiationInfo_JCEF((KeyGenerator) algorithm, parameters);
5718 initiate_JCEF(algorithm);
5719 }
5720
5721 /**
5722 * Define los parámetros de inicialización de un algoritmo traductor de
5723 * claves simétricas JCEF
5724 *
5725 * @param algorithm
5726 * Algoritmo traductor de claves simétricas JCEF
5727 * @param parameters
5728 * Parámetros de inicialización
5729 * @throws Throwable
5730 * Ocurre si no se ha podido realizar la operación
5731 * @see #initiate_JCEF(SymmetricKeyTranslator)
5732 * @see SymmetricKeyTranslator
5733 * @see #setInitiationInfo_JCEF(KeyTranslator, Map)
5734 * @see #setInitiationInfo_JCE(SecretKeyFactory, Map)
5735 */
5736 public static void setInitiationInfo_JCEF(SymmetricKeyTranslator algorithm,
5737 Map parameters) throws Throwable {
5738 setInitiationInfo_JCEF((KeyTranslator) algorithm, parameters);
5739 initiate_JCEF(algorithm);
5740 }
5741
5742 /**
5743 * Inicializa un algoritmo criptográfico de protección simétrica para su uso
5744 *
5745 * @param algorithm
5746 * Algoritmo criptográfico de protección simétrica
5747 * @param parameters
5748 * Parámetros de inicialización
5749 * @throws Throwable
5750 * Ocurre si no se ha podido realizar la operación
5751 * @see SymmetricProtection#setSymmetricKey(SecretKey)
5752 * @see SymmetricProtection#setSymmetricKey(KeySpec)
5753 * @see SymmetricProtection#setSymmetricKey(byte[])
5754 * @see SymmetricProtection
5755 * @see #setInitiationInfo_JCEF(Protection, Map)
5756 * @see #setInitiationInfo_JCEF(BlockSymmetricProtection, Map)
5757 * @see #setInitiationInfo_JCEF(StreamSymmetricProtection, Map)
5758 * @see #setInitiationInfo_JCEF(PBEProtection, Map)
5759 */
5760 public static void setInitiationInfo_JCEF(SymmetricProtection algorithm,
5761 Map parameters) throws Throwable {
5762 setInitiationInfo_JCEF((Protection) algorithm, parameters);
5763 Object symmetricKey = parameters.get("symmetricKey");
5764 if (symmetricKey instanceof SecretKey) {
5765 algorithm.setSymmetricKey((SecretKey) symmetricKey);
5766 } else if (symmetricKey instanceof KeySpec) {
5767 algorithm.setSymmetricKey((KeySpec) symmetricKey);
5768 } else {
5769 algorithm.setSymmetricKey((SecretKey) null);
5770 }
5771 }
5772
5773 /**
5774 * Define los parámetros de inicialización de un algoritmo traductor JCEF
5775 *
5776 * @param algorithm
5777 * Algoritmo traductor JCEF
5778 * @param parameters
5779 * Parámetros de inicialización
5780 * @throws Throwable
5781 * Ocurre si no se ha podido realizar la operación
5782 * @see Translator
5783 * @see #setInitiationInfo_JCEF(Algorithm, Map)
5784 * @see #setInitiationInfo_JCEF(KeyTranslator, Map)
5785 * @see #setInitiationInfo_JCEF(ParameterTranslator, Map)
5786 */
5787 public static void setInitiationInfo_JCEF(Translator algorithm,
5788 Map parameters) throws Throwable {
5789 setInitiationInfo_JCEF((Algorithm) algorithm, parameters);
5790 initiate_JCEF(algorithm);
5791 }
5792
5793 /**
5794 * Inicializa en modo protección un algoritmo criptográfico de protección
5795 * asimétrica
5796 *
5797 * @param algorithm
5798 * Algoritmo criptográfico de protección asimétrica
5799 * @param parameters
5800 * Parámetros de inicialización
5801 * @throws Throwable
5802 * Ocurre si no se ha podido realizar la operación
5803 * @see AsymmetricProtection#setProtectKey(PrivateKey)
5804 * @see AsymmetricProtection#setProtectKey(KeySpec)
5805 * @see AsymmetricProtection
5806 * @see #setInitiationInfo_JCEF(AsymmetricProtection, Map)
5807 * @see #setInitiationInfo_JCEF(Protection, Map)
5808 */
5809 public static void setInitiationInfo_JCEFForProtection(
5810 AsymmetricProtection algorithm, Map parameters) throws Throwable {
5811 setInitiationInfo_JCEF((Protection) algorithm, parameters);
5812 Object protectKey = parameters.get("protectKey");
5813 if (protectKey instanceof PublicKey) {
5814 algorithm.setProtectKey((PublicKey) protectKey);
5815 } else if (protectKey instanceof KeySpec) {
5816 algorithm.setProtectKey((KeySpec) protectKey);
5817 } else {
5818 algorithm.setProtectKey((PublicKey) null);
5819 }
5820 }
5821
5822 /**
5823 * Inicializa en modo protección un algoritmo criptográfico de protección
5824 * simétrica
5825 *
5826 * @param algorithm
5827 * Algoritmo criptográfico de protección simétrica
5828 * @param parameters
5829 * Parámetros de inicialización
5830 * @throws Throwable
5831 * Ocurre si no se ha podido realizar la operación
5832 * @see SymmetricProtection
5833 * @see #setInitiationInfo_JCEF(SymmetricProtection, Map)
5834 */
5835 public static void setInitiationInfo_JCEFForProtection(
5836 SymmetricProtection algorithm, Map parameters) throws Throwable {
5837 setInitiationInfo_JCEF((SymmetricProtection) algorithm, parameters);
5838 }
5839
5840 /**
5841 * Inicializa en modo desprotección un algoritmo criptográfico de protección
5842 * asimétrica
5843 *
5844 * @param algorithm
5845 * Algoritmo criptográfico de protección asimétrica
5846 * @param parameters
5847 * Parámetros de inicialización
5848 * @throws Throwable
5849 * Ocurre si no se ha podido realizar la operación
5850 * @see AsymmetricProtection#setUnprotectKey(PublicKey)
5851 * @see AsymmetricProtection#setUnprotectKey(KeySpec)
5852 * @see AsymmetricProtection
5853 * @see #setInitiationInfo_JCEF(AsymmetricProtection, Map)
5854 * @see #setInitiationInfo_JCEF(Protection, Map)
5855 */
5856 public static void setInitiationInfo_JCEFForUnprotection(
5857 AsymmetricProtection algorithm, Map parameters) throws Throwable {
5858 setInitiationInfo_JCEF((Protection) algorithm, parameters);
5859 Object unprotectKey = parameters.get("unprotectKey");
5860 if (unprotectKey instanceof PrivateKey) {
5861 algorithm.setUnprotectKey((PrivateKey) unprotectKey);
5862 } else if (unprotectKey instanceof KeySpec) {
5863 algorithm.setUnprotectKey((KeySpec) unprotectKey);
5864 } else {
5865 algorithm.setUnprotectKey((PrivateKey) null);
5866 }
5867 }
5868
5869 /**
5870 * Inicializa en modo desprotección un algoritmo criptográfico de protección
5871 * simétrica
5872 *
5873 * @param algorithm
5874 * Algoritmo criptográfico de protección simétrica
5875 * @param parameters
5876 * Parámetros de inicialización
5877 * @throws Throwable
5878 * Ocurre si no se ha podido realizar la operación
5879 * @see SymmetricProtection
5880 * @see #setInitiationInfo_JCEF(SymmetricProtection, Map)
5881 */
5882 public static void setInitiationInfo_JCEFForUnprotection(
5883 SymmetricProtection algorithm, Map parameters) throws Throwable {
5884 setInitiationInfo_JCEF((SymmetricProtection) algorithm, parameters);
5885 }
5886
5887 public static void setInitiationInfoForGeneration_JCE(Mac algorithm,
5888 Map parameters) throws InvalidKeyException,
5889 InvalidAlgorithmParameterException {
5890 setInitiationInfo_JCE(algorithm, parameters);
5891 initiateForGeneration_JCE(algorithm);
5892 }
5893
5894 /**
5895 * Define los parámetros de inicialización en modo generación de un
5896 * algoritmo criptográfico de autentificación mediante huellas digitales JCE
5897 *
5898 * @param algorithm
5899 * Algoritmo criptográfico de autentificación mediante huellas
5900 * digitales JCE
5901 * @param parameters
5902 * Parámetros de inicialización
5903 * @see #setInitiationInfo_JCE(MessageDigest, Map)
5904 * @see #initiateForGeneration_JCE(MessageDigest)
5905 */
5906 public static void setInitiationInfoForGeneration_JCE(
5907 MessageDigest algorithm, Map parameters) {
5908 setInitiationInfo_JCE(algorithm, parameters);
5909 initiateForGeneration_JCE(algorithm);
5910 }
5911
5912 public static void setInitiationInfoForGeneration_JCE(Signature algorithm,
5913 Map parameters) throws Throwable {
5914 PrivateKey signingKey = (PrivateKey) parameters.get("signingKey");
5915 AlgorithmParameterSpec parameter = (AlgorithmParameterSpec) parameters
5916 .get("parameter");
5917 SecureRandom random = (SecureRandom) parameters.get("random");
5918 Class parameterType = (Class) parameters.get("parameterType");
5919 initiateForGeneration_JCE(algorithm, signingKey, parameter, random,
5920 parameterType);
5921 }
5922
5923 /**
5924 * Inicializa en modo generación un algoritmo criptográfico de
5925 * autentificación mediante sellos digitales basados en contraseña
5926 *
5927 * @param algorithm
5928 * Algoritmo criptográfico de autentificación mediante sellos
5929 * digitales basados en contraseña
5930 * @param parameters
5931 * Parámetros de inicialización
5932 * @throws Throwable
5933 * Ocurre si no se ha podido realizar la operación
5934 * @see DigitalPBESeal
5935 * @see #setInitiationInfo_JCEF(DigitalSeal, Map)
5936 */
5937 public static void setInitiationInfoForGeneration_JCEF(
5938 DigitalPBESeal algorithm, Map parameters) throws Throwable {
5939 setInitiationInfo_JCEF((DigitalPBESeal) algorithm, parameters);
5940 initiateForGeneration_JCEF(algorithm);
5941 }
5942
5943 /**
5944 * Inicializa en modo generación un algoritmo criptográfico de
5945 * autentificación mediante sellos digitales
5946 *
5947 * @param algorithm
5948 * Algoritmo criptográfico de autentificación mediante sellos
5949 * digitales
5950 * @param parameters
5951 * Parámetros de inicialización
5952 * @throws Throwable
5953 * Ocurre si no se ha podido realizar la operación
5954 * @see DigitalSeal
5955 * @see #setInitiationInfo_JCEF(DigitalSeal, Map)
5956 */
5957 public static void setInitiationInfoForGeneration_JCEF(
5958 DigitalSeal algorithm, Map parameters) throws Throwable {
5959 setInitiationInfo_JCEF(algorithm, parameters);
5960 initiateForGeneration_JCEF(algorithm);
5961 }
5962
5963 /**
5964 * Inicializa en modo generación un algoritmo criptográfico de
5965 * autentificación mediante firmas digitales
5966 *
5967 * @param algorithm
5968 * Algoritmo criptográfico de autentificación mediante firmas
5969 * digitales
5970 * @param parameters
5971 * Parámetros de inicialización
5972 * @throws Throwable
5973 * Ocurre si no se ha podido realizar la operación
5974 * @see DigitalSignature#setSigningKey(PrivateKey)
5975 * @see DigitalSignature#setSigningKey(KeySpec)
5976 * @see DigitalSignature
5977 * @see #setInitiationInfo_JCEF(AuthenticationAlgorithm, Map)
5978 */
5979 public static void setInitiationInfoForGeneration_JCEF(
5980 DigitalSignature algorithm, Map parameters) throws Throwable {
5981 setInitiationInfo_JCEF((AuthenticationAlgorithm) algorithm, parameters);
5982 Object signingKey = parameters.get("signingKey");
5983 initiateForGeneration_JCEF(algorithm, signingKey);
5984 }
5985
5986 /**
5987 * Inicializa en modo generación un algoritmo criptográfico de
5988 * autentificación mediante huellas digitales JCEF
5989 *
5990 * @param algorithm
5991 * Algoritmo criptográfico de autentificación mediante huellas
5992 * digitales JCEF
5993 * @param parameters
5994 * Parámetros de inicialización
5995 * @throws Throwable
5996 * Ocurre si no se ha podido realizar la operación
5997 * @see #initiateForGeneration_JCEF(FingerPrint)
5998 * @see FingerPrint
5999 * @see #setInitiationInfo_JCEF(FingerPrint, Map)
6000 * @see #initiateForGeneration_JCE(MessageDigest)
6001 */
6002 public static void setInitiationInfoForGeneration_JCEF(
6003 FingerPrint algorithm, Map parameters) throws Throwable {
6004 setInitiationInfo_JCEF(algorithm, parameters);
6005 initiateForGeneration_JCEF(algorithm);
6006 }
6007
6008 public static void setInitiationInfoForVerification_JCE(Mac algorithm,
6009 Map parameters) throws InvalidKeyException,
6010 InvalidAlgorithmParameterException {
6011 setInitiationInfo_JCE(algorithm, parameters);
6012 initiateForVerification_JCE(algorithm);
6013 }
6014
6015 public static void setInitiationInfoForVerification_JCE(
6016 Signature algorithm, Map parameters) throws Throwable {
6017 PublicKey verifyKey = (PublicKey) parameters.get("verifyKey");
6018 AlgorithmParameterSpec parameter = (AlgorithmParameterSpec) parameters
6019 .get("parameter");
6020 initiateForVerification_JCE(algorithm, verifyKey, parameter);
6021 }
6022
6023 /**
6024 * Inicializa en modo verificación un algoritmo criptográfico de
6025 * autentificación mediante sellos digitales basados en contraseña
6026 *
6027 * @param algorithm
6028 * Algoritmo criptográfico de autentificación mediante sellos
6029 * digitales basados en contraseña
6030 * @param parameters
6031 * Parámetros de inicialización
6032 * @throws Throwable
6033 * Ocurre si no se ha podido realizar la operación
6034 * @see DigitalPBESeal
6035 * @see #setInitiationInfo_JCEF(DigitalSeal, Map)
6036 */
6037 public static void setInitiationInfoForVerification_JCEF(
6038 DigitalPBESeal algorithm, Map parameters) throws Throwable {
6039 setInitiationInfo_JCEF((DigitalPBESeal) algorithm, parameters);
6040 initiateForVerification_JCEF(algorithm);
6041 }
6042
6043 /**
6044 * Inicializa en modo verificación un algoritmo criptográfico de
6045 * autentificación mediante sellos digitales
6046 *
6047 * @param algorithm
6048 * Algoritmo criptográfico de autentificación mediante sellos
6049 * digitales
6050 * @param parameters
6051 * Parámetros de inicialización
6052 * @throws Throwable
6053 * Ocurre si no se ha podido realizar la operación
6054 * @see DigitalSeal
6055 * @see #setInitiationInfo_JCEF(DigitalSeal, Map)
6056 */
6057 public static void setInitiationInfoForVerification_JCEF(
6058 DigitalSeal algorithm, Map parameters) throws Throwable {
6059 setInitiationInfo_JCEF(algorithm, parameters);
6060 initiateForVerification_JCEF(algorithm);
6061 }
6062
6063 /**
6064 * Inicializa en modo verificación un algoritmo criptográfico de
6065 * autentificación mediante firmas digitales
6066 *
6067 * @param algorithm
6068 * Algoritmo criptográfico de autentificación mediante firmas
6069 * digitales
6070 * @param parameters
6071 * Parámetros de inicialización
6072 * @throws Throwable
6073 * Ocurre si no se ha podido realizar la operación
6074 * @see DigitalSignature#setVerifyKey(PublicKey)
6075 * @see DigitalSignature#setVerifyKey(KeySpec)
6076 * @see DigitalSignature
6077 * @see #setInitiationInfo_JCEF(AuthenticationAlgorithm, Map)
6078 */
6079 public static void setInitiationInfoForVerification_JCEF(
6080 DigitalSignature algorithm, Map parameters) throws Throwable {
6081 setInitiationInfo_JCEF((AuthenticationAlgorithm) algorithm, parameters);
6082 Object verifyKey = parameters.get("verifyKey");
6083 initiateForVerification_JCEF(algorithm, verifyKey);
6084 }
6085
6086 /**
6087 * Define los parámetros de inicialización en modo verificación de un
6088 * algoritmo criptográfico de autentificación mediante huellas digitales
6089 * JCEF
6090 *
6091 * @param algorithm
6092 * Algoritmo criptográfico de autentificación mediante huellas
6093 * digitales JCEF
6094 * @param parameters
6095 * Parámetros de inicialización
6096 * @throws Throwable
6097 * Ocurre si no se ha podido realizar la operación
6098 * @see #initiateForVerification_JCEF(FingerPrint)
6099 * @see FingerPrint
6100 * @see #setInitiationInfo_JCEF(FingerPrint, Map)
6101 */
6102 public static void setInitiationInfoForVerification_JCEF(
6103 FingerPrint algorithm, Map parameters) throws Throwable {
6104 setInitiationInfo_JCEF(algorithm, parameters);
6105 initiateForVerification_JCEF(algorithm);
6106 }
6107
6108 /**
6109 * Define los parámetros de inicialización en modo verificación de un
6110 * algoritmo criptográfico de autentificación mediante huellas digitales JCE
6111 *
6112 * @param algorithm
6113 * Algoritmo criptográfico de autentificación mediante huellas
6114 * digitales JCE
6115 * @param parameters
6116 * Parámetros de inicialización
6117 * @see #initiateForVerification_JCE(MessageDigest)
6118 * @see #setInitiationInfo_JCE(MessageDigest, Map)
6119 * @see MessageDigest
6120 */
6121 public static void setInitiationInfoForVerification_JCE(
6122 MessageDigest algorithm, Map parameters) {
6123 setInitiationInfo_JCE(algorithm, parameters);
6124 initiateForVerification_JCE(algorithm);
6125 }
6126
6127 }
6128
6129 /**
6130 * Aquí se muestran los proveedores JCEF disponibles, la mayoría son
6131 * adaptaciones de especificaciones JCE (todos los proveedores públicos JCE
6132 * existentes) y otros son proveedores de otras especificaciones Y los
6133 * proveedores disponibles para JCE. Además también se indica cómo se crean y
6134 * registran proveedores
6135 */
6136 public static class Providers {
6137
6138 /**
6139 * Selecciona proveedores JCEF que han sido adaptados desde la
6140 * especificación JCE
6141 *
6142 * @return Proveedores JCEF
6143 * @see BouncyCastleJCEFProvider
6144 * @see CryptixCryptoJCEFProvider
6145 * @see CryptixJCEFProvider
6146 * @see FlexiCoreJCEFProvider
6147 * @see FlexiECJCEFProvider
6148 * @see FlexiNFJCEFProvider
6149 * @see GNUCryptoJCEFProvider
6150 * @see IAIKJCEFProvider
6151 * @see JHBCIJCEFProvider
6152 * @see SUNJCEFProvider
6153 * @see SunJCEJCEFProvider
6154 * @see SunJSSEJCEFProvider
6155 * @see SunRsaSignJCEFProvider
6156 * @see JacksumJCEFProvider
6157 * @see LogiCryptoJCEFProvider
6158 * @see MindbrightJCEFProvider
6159 */
6160 public static JCEFProvider[] selectProviders_JCEF() {
6161 JCEFProvider[] result = null;
6162 result = new JCEFProvider[] { new BouncyCastleJCEFProvider(),
6163 new CryptixCryptoJCEFProvider(), new CryptixJCEFProvider(),
6164 new FlexiCoreJCEFProvider(), new FlexiECJCEFProvider(),
6165 new FlexiNFJCEFProvider(), new GNUCryptoJCEFProvider(),
6166 new IAIKJCEFProvider(), new JHBCIJCEFProvider(),
6167 new SUNJCEFProvider(), new SunJCEJCEFProvider(),
6168 new SunJSSEJCEFProvider(), new SunRsaSignJCEFProvider(),
6169 new JacksumJCEFProvider(), new LogiCryptoJCEFProvider(),
6170 new MindbrightJCEFProvider() };
6171 return result;
6172 }
6173
6174 /**
6175 * En JCEF, no hay que registrar los proveedores
6176 */
6177 public static void registerProviders_JCEF() {
6178 }
6179
6180 /**
6181 * Selecciona proveedores JCE
6182 *
6183 * @return Proveedores JCE
6184 * @see BouncyCastleProvider
6185 * @see CryptixCrypto
6186 * @see Cryptix
6187 * @see FlexiCoreProvider
6188 * @see FlexiECProvider
6189 * @see FlexiNFProvider
6190 * @see GnuCrypto
6191 * @see IAIK
6192 * @see JHBCI
6193 * @see Sun
6194 * @see SunJCE
6195 * @see com.sun.net.ssl.internal.ssl.Provider SunJSSE
6196 * @see SunRsaSign
6197 */
6198 public static Provider[] selectProviders_JCE() {
6199 Provider[] result = null;
6200 result = new Provider[] { new BouncyCastleProvider(),
6201 new CryptixCrypto(), new Cryptix(), new FlexiCoreProvider(),
6202 new FlexiECProvider(), new FlexiNFProvider(), new GnuCrypto(),
6203 new IAIK(), new JHBCI(), new Sun(), new SunJCE(),
6204 new com.sun.net.ssl.internal.ssl.Provider(), new SunRsaSign() };
6205 return result;
6206 }
6207
6208 /**
6209 * Para utilizar algoritmos con JCE, es necesario registrar los proveedores
6210 * que implementen dichos algoritmos en los modos 2 y 3 (véase
6211 * {@link SelectingAlgorithms})
6212 *
6213 * @see #selectProviders_JCE()
6214 */
6215 public static void registerProviders_JCE() {
6216 Provider providers[] = selectProviders_JCE();
6217 for (int i = 0; providers != null && i < providers.length; i++) {
6218 Security.addProvider(providers[i]);
6219 }
6220 }
6221
6222 }
6223
6224 /**
6225 * Muestra cómo seleccionar un algoritmo. En JCEF, basta con crear una instancia
6226 * del algoritmo que se desea utilizar. Por lo contrario, en JCE, es necesario
6227 * utilizar métodos estáticos para la selección del algoritmo que se desea
6228 * utilizar
6229 */
6230 public static class SelectingAlgorithms {
6231
6232 /**
6233 * Muestra cómo seleccionar algoritmos generadores de claves asimétricas
6234 *
6235 * @return Algoritmos generadores de claves asimétricas
6236 */
6237 public static AsymmetricKeyGenerator[] selectAsymmetricKeyGenerators() {
6238 AsymmetricKeyGenerator[] result = null;
6239 result = new AsymmetricKeyGenerator[] {
6240 new DSAAsymmetricKeyGenerator_BouncyCastle(),
6241 new DSAAsymmetricKeyGenerator_CryptixCrypto(),
6242 new ElGamalAsymmetricKeyGenerator_Cryptix(),
6243 new RSAAsymmetricKeyGenerator_FlexiCore(),
6244 new ECAsymmetricKeyGenerator_FlexiEC(),
6245 new IQGQAsymmetricKeyGenerator_FlexiNF(),
6246 new RSAAsymmetricKeyGenerator_GNUCrypto(),
6247 new RSAAsymmetricKeyGenerator_IAIK(),
6248 new RSAAsymmetricKeyGenerator_JHBCI(),
6249 new RSAAsymmetricKeyGenerator_LogiCrypto(),
6250 new DSAAsymmetricKeyGenerator_Mindbright(),
6251 new DSAAsymmetricKeyGenerator_SUN(),
6252 new RSAAsymmetricKeyGenerator_SunRsaSign() };
6253 return result;
6254 }
6255
6256 /**
6257 * Muestra una forma (modo 1) sobre cómo seleccionar algoritmos generadores
6258 * de claves asimétricas
6259 *
6260 * @return Algoritmos generadores de claves asimétricas
6261 * @throws NoSuchAlgorithmException
6262 * @see KeyPairGenerator#getInstance(java.lang.String,
6263 * java.security.Provider)
6264 * @see KeyPairGenerator
6265 */
6266 public static KeyPairGenerator[] selectAsymmetricKeyGeneratorsMode1_JCE()
6267 throws NoSuchAlgorithmException {
6268 KeyPairGenerator[] result = null;
6269 result = new KeyPairGenerator[] {
6270 KeyPairGenerator.getInstance("DSA", new BouncyCastleProvider()),
6271 KeyPairGenerator.getInstance("DSA", new CryptixCrypto()),
6272 KeyPairGenerator.getInstance("ElGamal", new Cryptix()),
6273 KeyPairGenerator.getInstance("RSA", new FlexiCoreProvider()),
6274 KeyPairGenerator.getInstance("EC", new FlexiECProvider()),
6275 KeyPairGenerator.getInstance("IQGQ", new FlexiNFProvider()),
6276 KeyPairGenerator.getInstance("RSA", new GnuCrypto()),
6277 KeyPairGenerator.getInstance("RSA", new IAIK()),
6278 KeyPairGenerator.getInstance("RSA", new JHBCI()),
6279 KeyPairGenerator.getInstance("DSA", new Sun()),
6280 KeyPairGenerator.getInstance("RSA", new SunRsaSign()) };
6281 return result;
6282 }
6283
6284 /**
6285 * Muestra una forma (modo 2) sobre cómo seleccionar algoritmos generadores
6286 * de claves asimétricas
6287 *
6288 * @return Algoritmos generadores de claves asimétricas
6289 * @throws NoSuchProviderException
6290 * @throws NoSuchAlgorithmException
6291 * @see KeyPairGenerator#getInstance(java.lang.String, java.lang.String)
6292 * @see KeyPairGenerator
6293 * @see Providers#registerProviders_JCE()
6294 */
6295 public static KeyPairGenerator[] selectAsymmetricKeyGeneratorsMode2_JCE()
6296 throws NoSuchAlgorithmException, NoSuchProviderException {
6297 KeyPairGenerator[] result = null;
6298 Providers.registerProviders_JCE();
6299 result = new KeyPairGenerator[] {
6300 KeyPairGenerator.getInstance("DSA", "BC"),
6301 KeyPairGenerator.getInstance("DSA", "CryptixCrypto"),
6302 KeyPairGenerator.getInstance("ElGamal", "Cryptix"),
6303 KeyPairGenerator.getInstance("RSA", "FlexiCore"),
6304 KeyPairGenerator.getInstance("EC", "FlexiEC"),
6305 KeyPairGenerator.getInstance("IQGQ", "FlexiNF"),
6306 KeyPairGenerator.getInstance("RSA", "GNU-CRYPTO"),
6307 KeyPairGenerator.getInstance("RSA", "IAIK"),
6308 KeyPairGenerator.getInstance("RSA", "JHBCI"),
6309 KeyPairGenerator.getInstance("DSA", "SUN"),
6310 KeyPairGenerator.getInstance("RSA", "SunRsaSign") };
6311 return result;
6312 }
6313
6314 /**
6315 * Muestra una forma (modo 3) sobre cómo seleccionar algoritmos generadores
6316 * de claves asimétricas
6317 *
6318 * @return Algoritmos generadores de claves asimétricas
6319 * @throws NoSuchAlgorithmException
6320 * @see KeyPairGenerator#getInstance(java.lang.String)
6321 * @see KeyPairGenerator
6322 * @see Providers#registerProviders_JCE()
6323 */
6324 public static KeyPairGenerator[] selectAsymmetricKeyGeneratorsMode3_JCE()
6325 throws NoSuchAlgorithmException {
6326 KeyPairGenerator[] result = null;
6327 Providers.registerProviders_JCE();
6328 result = new KeyPairGenerator[] { KeyPairGenerator.getInstance("DSA"),
6329 KeyPairGenerator.getInstance("ElGamal"),
6330 KeyPairGenerator.getInstance("RSA"),
6331 KeyPairGenerator.getInstance("EC"),
6332 KeyPairGenerator.getInstance("IQGQ") };
6333 return result;
6334 }
6335
6336 /**
6337 * Muestra cómo seleccionar algoritmos traductores de claves asimétricas con
6338 * especificación JCEF
6339 *
6340 * @return Algoritmos traductores de claves asimétricas
6341 */
6342 public static AsymmetricKeyTranslator[] selectAsymmetricKeyTranslators() {
6343 AsymmetricKeyTranslator[] result = null;
6344 result = new AsymmetricKeyTranslator[] {
6345 new DSAAsymmetricKeyTranslator_BouncyCastle(),
6346 new DSAAsymmetricKeyTranslator_CryptixCrypto(),
6347 new RSAAsymmetricKeyTranslator_FlexiCore(),
6348 new ECNRAsymmetricKeyTranslator_FlexiEC(),
6349 new IQRDSAAsymmetricKeyTranslator_FlexiNF(),
6350 new RSAAsymmetricKeyTranslator_IAIK(),
6351 new RSAAsymmetricKeyTranslator_JHBCI(),
6352 new RSAAsymmetricKeyTranslator_LogiCrypto(),
6353 new DSAAsymmetricKeyTranslator_Mindbright(),
6354 new DSAAsymmetricKeyTranslator_SUN(),
6355 new RSAAsymmetricKeyTranslator_SunRsaSign() };
6356 return result;
6357 }
6358
6359 /**
6360 * Muestra una forma (modo 1) sobre cómo seleccionar algoritmos traductores
6361 * de claves asimétricas con especificación JCE
6362 *
6363 * @return Algoritmos traductores de claves asimétricas con especificación
6364 * JCE
6365 * @throws NoSuchAlgorithmException
6366 */
6367 public static KeyFactory[] selectAsymmetricKeyTranslatorsMode1_JCE()
6368 throws NoSuchAlgorithmException {
6369 KeyFactory[] result = null;
6370 result = new KeyFactory[] {
6371 KeyFactory.getInstance("DSA", new BouncyCastleProvider()),
6372 KeyFactory.getInstance("DSA", new CryptixCrypto()),
6373 KeyFactory.getInstance("RSA", new FlexiCoreProvider()),
6374 KeyFactory.getInstance("ECNR", new FlexiECProvider()),
6375 KeyFactory.getInstance("IQRDSA", new FlexiNFProvider()),
6376 KeyFactory.getInstance("RSA", new IAIK()),
6377 KeyFactory.getInstance("RSA", new JHBCI()),
6378 KeyFactory.getInstance("DSA", new Sun()),
6379 KeyFactory.getInstance("RSA", new SunRsaSign()) };
6380 return result;
6381 }
6382
6383 /**
6384 * Muestra una forma (modo 2) sobre cómo seleccionar algoritmos traductores
6385 * de claves asimétricas con especificación JCE
6386 *
6387 * @return Algoritmos traductores de claves asimétricas con especificación
6388 * JCE
6389 * @throws NoSuchProviderException
6390 * @throws NoSuchAlgorithmException
6391 * @see Providers#registerProviders_JCE()
6392 */
6393 public static KeyFactory[] selectAsymmetricKeyTranslatorsMode2_JCE()
6394 throws NoSuchAlgorithmException, NoSuchProviderException {
6395 KeyFactory[] result = null;
6396 Providers.registerProviders_JCE();
6397 result = new KeyFactory[] { KeyFactory.getInstance("DSA", "BC"),
6398 KeyFactory.getInstance("DSA", "CryptixCrypto"),
6399 KeyFactory.getInstance("RSA", "FlexiCore"),
6400 KeyFactory.getInstance("ECNR", "FlexiEC"),
6401 KeyFactory.getInstance("IQRDSA", "FlexiNF"),
6402 KeyFactory.getInstance("RSA", "IAIK"),
6403 KeyFactory.getInstance("RSA", "JHBCI"),
6404 KeyFactory.getInstance("DSA", "SUN"),
6405 KeyFactory.getInstance("RSA", "SunRsaSign") };
6406 return result;
6407 }
6408
6409 /**
6410 * Muestra una forma (modo 3) sobre cómo seleccionar algoritmos traductores
6411 * de claves asimétricas con especificación JCE
6412 *
6413 * @return Algoritmos traductores de claves asimétricas con especificación
6414 * JCE
6415 * @throws NoSuchAlgorithmException
6416 * @see Providers#registerProviders_JCE()
6417 */
6418 public static KeyFactory[] selectAsymmetricKeyTranslatorsMode3_JCE()
6419 throws NoSuchAlgorithmException {
6420 KeyFactory[] result = null;
6421 Providers.registerProviders_JCE();
6422 result = new KeyFactory[] { KeyFactory.getInstance("DSA"),
6423 KeyFactory.getInstance("RSA"), KeyFactory.getInstance("ECNR"),
6424 KeyFactory.getInstance("IQRDSA") };
6425 return result;
6426 }
6427
6428 /**
6429 * Muestra cómo seleccionar algoritmos criptográficos de protección
6430 * asimétrica con especificación JCEF
6431 *
6432 * @return Algoritmos criptográficos de protección asimétrica con
6433 * especificación JCEF
6434 */
6435 public static AsymmetricProtection[] selectAsymmetricProtections() {
6436 AsymmetricProtection[] result = null;
6437 result = new AsymmetricProtection[] {
6438 new RSA_ISO97961_AP_BC(),
6439 new ElGamal_PKCS1_AP_CryptixCrypto(),
6440 new ElGamalAsymmetricProtection_Cryptix(),
6441 new ElGamalAsymmetricProtection_FlexiCore(),
6442 new IESGF2nAsymmetricProtection_FlexiEC(),
6443 new RSAwithOAEPwithMD5andMGF1PaddingAsymmetricProtection_IAIK(),
6444 new RSAAsymmetricProtection_JHBCI(),
6445 new RSAAsymmetricProtection_LogiCrypto(),
6446 new RSAwithOAEPwithSHA256andMGF1PaddingAsymmetricProtection_SunJCE() };
6447 return result;
6448 }
6449
6450 /**
6451 * Muestra una forma (modo 1) sobre cómo seleccionar algoritmos
6452 * criptográficos de protección asimétrica con especificación JCE
6453 *
6454 * @return Algoritmos criptográficos de protección asimétrica con
6455 * especificación JCE
6456 * @throws NoSuchPaddingException
6457 * @throws NoSuchAlgorithmException
6458 */
6459 public static Cipher[] selectAsymmetricProtectionsMode1_JCE()
6460 throws NoSuchAlgorithmException, NoSuchPaddingException {
6461 Cipher[] result = null;
6462 result = new Cipher[] {
6463 Cipher.getInstance("RSA/ISO9796-1", new BouncyCastleProvider()),
6464 Cipher.getInstance("ElGamal/ECB/PKCS#1", new CryptixCrypto()),
6465 Cipher.getInstance("ElGamal", new Cryptix()),
6466 Cipher.getInstance("ElGamal", new FlexiCoreProvider()),
6467 Cipher.getInstance("IESGF2n", new FlexiECProvider()),
6468 Cipher.getInstance("RSA/NONE/OAEPwithMD5andMGF1Padding",
6469 new IAIK()),
6470 Cipher.getInstance("RSA", new JHBCI()),
6471 Cipher.getInstance("RSA/NONE/OAEPwithSHA-256andMGF1Padding",
6472 new SunJCE()) };
6473 return result;
6474 }
6475
6476 /**
6477 * Muestra una forma (modo 2) sobre cómo seleccionar algoritmos
6478 * criptográficos de protección asimétrica con especificación JCE
6479 *
6480 * @return Algoritmos criptográficos de protección asimétrica con
6481 * especificación JCE
6482 * @throws NoSuchPaddingException
6483 * @throws NoSuchProviderException
6484 * @throws NoSuchAlgorithmException
6485 * @see Providers#registerProviders_JCE()
6486 */
6487 public static Cipher[] selectAsymmetricProtectionsMode2_JCE()
6488 throws NoSuchAlgorithmException, NoSuchProviderException,
6489 NoSuchPaddingException {
6490 Cipher[] result = null;
6491 Providers.registerProviders_JCE();
6492 result = new Cipher[] {
6493 Cipher.getInstance("RSA/ISO9796-1", "BC"),
6494 Cipher.getInstance("ElGamal/ECB/PKCS#1", "CryptixCrypto"),
6495 Cipher.getInstance("ElGamal", "Cryptix"),
6496 Cipher.getInstance("ElGamal", "FlexiCore"),
6497 Cipher.getInstance("IESGF2n", "FlexiEC"),
6498 Cipher
6499 .getInstance("RSA/NONE/OAEPwithMD5andMGF1Padding",
6500 "IAIK"),
6501 Cipher.getInstance("RSA", "JHBCI"),
6502 Cipher.getInstance("RSA/NONE/OAEPwithSHA-256andMGF1Padding",
6503 "SunJCE") };
6504 return result;
6505 }
6506
6507 /**
6508 * Muestra una forma (modo 3) sobre cómo seleccionar algoritmos
6509 * criptográficos de protección asimétrica con especificación JCE
6510 *
6511 * @return Algoritmos criptográficos de protección asimétrica con
6512 * especificación JCE
6513 * @throws NoSuchPaddingException
6514 * @throws NoSuchAlgorithmException
6515 * @see Providers#registerProviders_JCE()
6516 */
6517 public static Cipher[] selectAsymmetricProtectionsMode3_JCE()
6518 throws NoSuchAlgorithmException, NoSuchPaddingException {
6519 Cipher[] result = null;
6520 Providers.registerProviders_JCE();
6521 result = new Cipher[] { Cipher.getInstance("RSA/ISO9796-1"),
6522 Cipher.getInstance("ElGamal/ECB/PKCS#1"),
6523 Cipher.getInstance("ElGamal"), Cipher.getInstance("IESGF2n"),
6524 Cipher.getInstance("RSA/NONE/OAEPwithMD5andMGF1Padding"),
6525 Cipher.getInstance("RSA"),
6526 Cipher.getInstance("RSA/NONE/OAEPwithSHA-256andMGF1Padding") };
6527 return result;
6528 }
6529
6530 /**
6531 * Muestra cómo seleccionar algoritmos criptográficos de protección
6532 * simétrica de bloques
6533 *
6534 * @return Algoritmos criptográficos de protección simétrica de bloques
6535 */
6536 public static BlockSymmetricProtection[] selectBlockSymmetricProtections() {
6537 BlockSymmetricProtection[] result = null;
6538 result = new BlockSymmetricProtection[] {
6539 new AESBlockSymmetricProtection_BouncyCastle(),
6540 new AESBlockSymmetricProtection_CryptixCrypto(),
6541 new SquareBlockSymmetricProtection_Cryptix(),
6542 new MARSBlockSymmetricProtection_FlexiCore(),
6543 new KhazadBlockSymmetricProtection_GNUCrypto(),
6544 new SerpentBlockSymmetricProtection_IAIK(),
6545 new DESBlockSymmetricProtection_JHBCI(),
6546 new CaesarBlockSymmetricProtection_LogiCrypto(),
6547 new TwofishBlockSymmetricProtection_Mindbright(),
6548 new AES192BlockSymmetricProtection_SunJCE() };
6549 return result;
6550 }
6551
6552 /**
6553 * Muestra una forma (modo 1) sobre cómo seleccionar algoritmos
6554 * criptográficos de protección simétrica de bloques
6555 *
6556 * @return Algoritmos criptográficos de protección simétrica de bloques
6557 * @throws NoSuchPaddingException
6558 * @throws NoSuchAlgorithmException
6559 */
6560 public static Cipher[] selectBlockSymmetricProtectionsMode1_JCE()
6561 throws NoSuchAlgorithmException, NoSuchPaddingException {
6562 Cipher[] result = null;
6563 Providers.registerProviders_JCE();
6564 result = new Cipher[] {
6565 Cipher.getInstance("RIJNDAEL128", new BouncyCastleProvider()),
6566 Cipher.getInstance("Rijndael", new CryptixCrypto()),
6567 Cipher.getInstance("Square", new Cryptix()),
6568 Cipher.getInstance("MARS", new FlexiCoreProvider()),
6569 Cipher.getInstance("KHAZAD", new GnuCrypto()),
6570 Cipher.getInstance("Serpent", new IAIK()),
6571 Cipher.getInstance("DES", new JHBCI()),
6572 Cipher.getInstance("AES192", new SunJCE()) };
6573 return result;
6574 }
6575
6576 /**
6577 * Muestra una forma (modo 2) sobre cómo seleccionar algoritmos
6578 * criptográficos de protección simétrica de bloques
6579 *
6580 * @return Algoritmos criptográficos de protección simétrica de bloques
6581 * @throws NoSuchPaddingException
6582 * @throws NoSuchAlgorithmException
6583 * @throws NoSuchProviderException
6584 * @see Providers#registerProviders_JCE()
6585 */
6586 public static Cipher[] selectBlockSymmetricProtectionsMode2_JCE()
6587 throws NoSuchAlgorithmException, NoSuchPaddingException,
6588 NoSuchProviderException {
6589 Cipher[] result = null;
6590 Providers.registerProviders_JCE();
6591 result = new Cipher[] { Cipher.getInstance("RIJNDAEL128", "BC"),
6592 Cipher.getInstance("Rijndael", "CryptixCrypto"),
6593 Cipher.getInstance("Square", "Cryptix"),
6594 Cipher.getInstance("MARS", "FlexiCore"),
6595 Cipher.getInstance("KHAZAD", "GNU-CRYPTO"),
6596 Cipher.getInstance("Serpent", "IAIK"),
6597 Cipher.getInstance("DES", "JHBCI"),
6598 Cipher.getInstance("AES192", "SunJCE") };
6599 return result;
6600 }
6601
6602 /**
6603 * Muestra una forma (modo 3) sobre cómo seleccionar algoritmos
6604 * criptográficos de protección simétrica de bloques
6605 *
6606 * @return Algoritmos criptográficos de protección simétrica de bloques
6607 * @throws NoSuchPaddingException
6608 * @throws NoSuchAlgorithmException
6609 * @throws NoSuchProviderException
6610 * @see Providers#registerProviders_JCE()
6611 */
6612 public static Cipher[] selectBlockSymmetricProtectionsMode3_JCE()
6613 throws NoSuchAlgorithmException, NoSuchPaddingException,
6614 NoSuchProviderException {
6615 Cipher[] result = null;
6616 Providers.registerProviders_JCE();
6617 result = new Cipher[] { Cipher.getInstance("RIJNDAEL128"),
6618 Cipher.getInstance("Rijndael"), Cipher.getInstance("Square"),
6619 Cipher.getInstance("MARS"), Cipher.getInstance("KHAZAD"),
6620 Cipher.getInstance("Serpent"), Cipher.getInstance("DES"),
6621 Cipher.getInstance("AES192") };
6622 return result;
6623 }
6624
6625 /**
6626 * Muestra cómo seleccionar algoritmos criptográficos de autentificación
6627 * mediante sellos digitales basado en contraseña
6628 *
6629 * @return Algoritmos criptográficos de autentificación mediante sellos
6630 * digitales basado en contraseña
6631 */
6632 public static DigitalPBESeal[] selectDigitalPBESeals() {
6633 DigitalPBESeal[] result = null;
6634 result = new DigitalPBESeal[] {
6635 new PBEHmacRIPEMD160DigitalPBESeal_BouncyCastle(),
6636 new PBEHmacSHA1DigitalPBESeal_SunJCE() };
6637 return result;
6638 }
6639
6640 /**
6641 * Muestra una forma (modo 1) sobre cómo seleccionar algoritmos
6642 * criptográficos de autentificación mediante sellos digitales basado en
6643 * contraseña con especificación JCE
6644 *
6645 * @return Algoritmos criptográficos de autentificación mediante sellos
6646 * digitales basado en contraseña con especificación JCE
6647 * @throws NoSuchAlgorithmException
6648 */
6649 public static Mac[] selectDigitalPBESealsMode1_JCE()
6650 throws NoSuchAlgorithmException {
6651 Mac[] result = null;
6652 result = new Mac[] {
6653 Mac.getInstance("PBEWITHHMACRIPEMD160",
6654 new BouncyCastleProvider()),
6655 Mac.getInstance("HmacPBESHA1", new SunJCE()) };
6656 return result;
6657 }
6658
6659 /**
6660 * Muestra una forma (modo 2) sobre cómo seleccionar algoritmos
6661 * criptográficos de autentificación mediante sellos digitales basado en
6662 * contraseña con especificación JCE
6663 *
6664 * @return Algoritmos criptográficos de autentificación mediante sellos
6665 * digitales basado en contraseña con especificación JCE
6666 * @throws NoSuchProviderException
6667 * @throws NoSuchAlgorithmException
6668 * @see Providers#registerProviders_JCE()
6669 */
6670 public static Mac[] selectDigitalPBESealsMode2_JCE()
6671 throws NoSuchAlgorithmException, NoSuchProviderException {
6672 Mac[] result = null;
6673 Providers.registerProviders_JCE();
6674 result = new Mac[] { Mac.getInstance("PBEWITHHMACRIPEMD160", "BC"),
6675 Mac.getInstance("HmacPBESHA1", "SunJCE") };
6676 return result;
6677 }
6678
6679 /**
6680 * Muestra una forma (modo 3) sobre cómo seleccionar algoritmos
6681 * criptográficos de autentificación mediante sellos digitales basado en
6682 * contraseña con especificación JCE
6683 *
6684 * @return Algoritmos criptográficos de autentificación mediante sellos
6685 * digitales basado en contraseña con especificación JCE
6686 * @throws NoSuchAlgorithmException
6687 * @see Providers#registerProviders_JCE()
6688 */
6689 public static Mac[] selectDigitalPBESealsMode3_JCE()
6690 throws NoSuchAlgorithmException {
6691 Mac[] result = null;
6692 Providers.registerProviders_JCE();
6693 result = new Mac[] { Mac.getInstance("PBEWITHHMACRIPEMD160"),
6694 Mac.getInstance("HmacPBESHA1") };
6695 return result;
6696 }
6697
6698 /**
6699 * Muestra cómo seleccionar algoritmos criptográficos de autentificación
6700 * mediante sellos digitales basado
6701 *
6702 * @return Algoritmos criptográficos de autentificación mediante sellos
6703 * digitales basado
6704 */
6705 public static DigitalSeal[] selectDigitalSeals() {
6706 DigitalSeal[] result = null;
6707 result = new DigitalSeal[] { new HmacMD2DigitalSeal_BouncyCastle(),
6708 new HmacMD5DigitalSeal_CryptixCrypto(),
6709 new HmacRIPEMD160DigitalSeal_Cryptix(),
6710 new HmacSHA512DigitalSeal_FlexiCore(),
6711 new HmacHavalDigitalSeal_GNUCrypto(),
6712 new HmacSHA224DigitalSeal_IAIK(),
6713 new HmacSHA1DigitalSeal_Mindbright(),
6714 new HmacSHA256DigitalSeal_SunJCE() };
6715 return result;
6716 }
6717
6718 /**
6719 * Muestra una forma (modo 1) sobre cómo seleccionar algoritmos
6720 * criptográficos de autentificación mediante sellos digitales basado con
6721 * especificación JCE
6722 *
6723 * @return Algoritmos criptográficos de autentificación mediante sellos
6724 * digitales basado con especificación JCE
6725 * @throws NoSuchAlgorithmException
6726 */
6727 public static Mac[] selectDigitalSealsMode1_JCE()
6728 throws NoSuchAlgorithmException {
6729 Mac[] result = null;
6730 result = new Mac[] {
6731 Mac.getInstance("HmacMD2", new BouncyCastleProvider()),
6732 Mac.getInstance("HMAC-MD5", new CryptixCrypto()),
6733 Mac.getInstance("HMAC-RIPEMD160", new Cryptix()),
6734 Mac.getInstance("HmacSHA512", new FlexiCoreProvider()),
6735 Mac.getInstance("HMAC-HAVAL", new GnuCrypto()),
6736 Mac.getInstance("HMAC/SHA224", new IAIK()),
6737 Mac.getInstance("HmacSHA256", new SunJCE()) };
6738 return result;
6739 }
6740
6741 /**
6742 * Muestra una forma (modo 2) sobre cómo seleccionar algoritmos
6743 * criptográficos de autentificación mediante sellos digitales basado con
6744 * especificación JCE
6745 *
6746 * @return Algoritmos criptográficos de autentificación mediante sellos
6747 * digitales basado con especificación JCE
6748 * @throws NoSuchProviderException
6749 * @throws NoSuchAlgorithmException
6750 * @see Providers#registerProviders_JCE()
6751 */
6752 public static Mac[] selectDigitalSealsMode2_JCE()
6753 throws NoSuchAlgorithmException, NoSuchProviderException {
6754 Mac[] result = null;
6755 Providers.registerProviders_JCE();
6756 result = new Mac[] { Mac.getInstance("HmacMD2", "BC"),
6757 Mac.getInstance("HMAC-MD5", "CryptixCrypto"),
6758 Mac.getInstance("HMAC-RIPEMD160", "Cryptix"),
6759 Mac.getInstance("HmacSHA512", "FlexiCore"),
6760 Mac.getInstance("HMAC-HAVAL", "GNU-CRYPTO"),
6761 Mac.getInstance("HMAC/SHA224", "IAIK"),
6762 Mac.getInstance("HmacSHA256", "SunJCE") };
6763 return result;
6764 }
6765
6766 /**
6767 * Muestra una forma (modo 3) sobre cómo seleccionar algoritmos
6768 * criptográficos de autentificación mediante sellos digitales basado con
6769 * especificación JCE
6770 *
6771 * @return Algoritmos criptográficos de autentificación mediante sellos
6772 * digitales basado con especificación JCE
6773 * @throws NoSuchAlgorithmException
6774 * @see Providers#registerProviders_JCE()
6775 */
6776 public static Mac[] selectDigitalSealsMode3_JCE()
6777 throws NoSuchAlgorithmException {
6778 Mac[] result = null;
6779 Providers.registerProviders_JCE();
6780 result = new Mac[] { Mac.getInstance("HmacMD2"),
6781 Mac.getInstance("HMAC-MD5"), Mac.getInstance("HMAC-RIPEMD160"),
6782 Mac.getInstance("HmacSHA512"), Mac.getInstance("HMAC-HAVAL"),
6783 Mac.getInstance("HMAC/SHA224"), Mac.getInstance("HmacSHA256") };
6784 return result;
6785 }
6786
6787 /**
6788 * Muestra cómo seleccionar algoritmos criptográficos de autentificación
6789 * mediante firmas digitales
6790 *
6791 * @return Algoritmos criptográficos de autentificación mediante firmas
6792 * digitales
6793 */
6794 public static DigitalSignature[] selectDigitalSignatures() {
6795 DigitalSignature[] result = null;
6796 result = new DigitalSignature[] {
6797 new RIPEMD256withRSADigitalSignature_BouncyCastle(),
6798 new MD2withRSADigitalSignature_CryptixCrypto(),
6799 new SHA1withElGamalDigitalSignature_Cryptix(),
6800 new RIPEMD160withRawRSADigitalSignature_FlexiCore(),
6801 new SHA1withECNRGF2nDigitalSignature_FlexiEC(),
6802 new SHA1withIQGQDigitalSignature_FlexiNF(),
6803 new NONEwithRSAandPSSDigitalSignature_GNUCrypto(),
6804 new SHA512withRSADigitalSignature_IAIK(),
6805 new RIPEMD160withRSAandISO97961DigitalSignature_JHBCI(),
6806 new SHA1withDSADigitalSignature_Mindbright(),
6807 new NONEwithDSADigitalSignature_SUN(),
6808 new MD5andSHA1withRSADigitalSignature_SunJSSE(),
6809 new SHA1withRSADigitalSignature_SunRsaSign() };
6810 return result;
6811 }
6812
6813 /**
6814 * Muestra una forma (modo 1) sobre cómo seleccionar algoritmos
6815 * criptográficos de autentificación mediante firmas digitales con
6816 * especificación JCE
6817 *
6818 * @return Algoritmos criptográficos de autentificación mediante firmas
6819 * digitales con especificación JCE
6820 * @throws NoSuchAlgorithmException
6821 */
6822 public static Signature[] selectDigitalSignaturesMode1_JCE()
6823 throws NoSuchAlgorithmException {
6824 Signature[] result = null;
6825 result = new Signature[] {
6826 Signature.getInstance("RIPEMD256WithRSAEncryption",
6827 new BouncyCastleProvider()),
6828 Signature.getInstance("MD2withRSA", new CryptixCrypto()),
6829 Signature.getInstance("SHA-1/ElGamal/PKCS#1", new Cryptix()),
6830 Signature.getInstance("RipeMD160/RSA/RAW",
6831 new FlexiCoreProvider()),
6832 Signature.getInstance("SHA1withECNR", new FlexiECProvider()),
6833 Signature.getInstance("SHA1withIQGQ", new FlexiNFProvider()),
6834 Signature.getInstance("RSA-PSS/RAW", new GnuCrypto()),
6835 Signature.getInstance("SHA512/RSA", new IAIK()),
6836 Signature.getInstance("RIPEMD160withRSAandISO97961",
6837 new JHBCI()),
6838 Signature.getInstance("NONEwithDSA", new Sun()),
6839 Signature.getInstance("MD5andSHA1withRSA",
6840 new com.sun.net.ssl.internal.ssl.Provider()),
6841 Signature.getInstance("SHA1withRSA", new SunRsaSign()) };
6842 return result;
6843 }
6844
6845 /**
6846 * Muestra una forma (modo 2) sobre cómo seleccionar algoritmos
6847 * criptográficos de autentificación mediante firmas digitales con
6848 * especificación JCE
6849 *
6850 * @return Algoritmos criptográficos de autentificación mediante firmas
6851 * digitales con especificación JCE
6852 * @throws NoSuchProviderException
6853 * @throws NoSuchAlgorithmException
6854 * @see Providers#registerProviders_JCE()
6855 */
6856 public static Signature[] selectDigitalSignaturesMode2_JCE()
6857 throws NoSuchAlgorithmException, NoSuchProviderException {
6858 Signature[] result = null;
6859 Providers.registerProviders_JCE();
6860 result = new Signature[] {
6861 Signature.getInstance("RIPEMD256WithRSAEncryption", "BC"),
6862 Signature.getInstance("MD2withRSA", "CryptixCrypto"),
6863 Signature.getInstance("SHA-1/ElGamal/PKCS#1", "Cryptix"),
6864 Signature.getInstance("RipeMD160/RSA/RAW", "FlexiCore"),
6865 Signature.getInstance("SHA1withECNR", "FlexiEC"),
6866 Signature.getInstance("SHA1withIQGQ", "FlexiNF"),
6867 Signature.getInstance("RSA-PSS/RAW", "GNU-CRYPTO"),
6868 Signature.getInstance("SHA512/RSA", "IAIK"),
6869 Signature.getInstance("RIPEMD160withRSAandISO97961", "JHBCI"),
6870 Signature.getInstance("NONEwithDSA", "SUN"),
6871 Signature.getInstance("MD5andSHA1withRSA", "SunJSSE"),
6872 Signature.getInstance("SHA1withRSA", "SunRsaSign") };
6873 return result;
6874 }
6875
6876 /**
6877 * Muestra una forma (modo 3) sobre cómo seleccionar algoritmos
6878 * criptográficos de autentificación mediante firmas digitales con
6879 * especificación JCE
6880 *
6881 * @return Algoritmos criptográficos de autentificación mediante firmas
6882 * digitales con especificación JCE
6883 * @throws NoSuchAlgorithmException
6884 * @see Providers#registerProviders_JCE()
6885 */
6886 public static Signature[] selectDigitalSignaturesMode3_JCE()
6887 throws NoSuchAlgorithmException {
6888 Signature[] result = null;
6889 Providers.registerProviders_JCE();
6890 result = new Signature[] {
6891 Signature.getInstance("RIPEMD256WithRSAEncryption"),
6892 Signature.getInstance("MD2withRSA"),
6893 Signature.getInstance("SHA-1/ElGamal/PKCS#1"),
6894 Signature.getInstance("RipeMD160/RSA/RAW"),
6895 Signature.getInstance("SHA1withECNR"),
6896 Signature.getInstance("SHA1withIQGQ"),
6897 Signature.getInstance("RSA-PSS/RAW"),
6898 Signature.getInstance("SHA512/RSA"),
6899 Signature.getInstance("RIPEMD160withRSAandISO97961"),
6900 Signature.getInstance("NONEwithDSA"),
6901 Signature.getInstance("MD5andSHA1withRSA"),
6902 Signature.getInstance("SHA1withRSA") };
6903 return result;
6904 }
6905
6906 /**
6907 * Muestra cómo seleccionar algoritmos criptográficos de autentificación
6908 * mediante huellas digitales
6909 *
6910 * @return Algoritmos criptográficos de autentificación mediante huellas
6911 * digitales
6912 */
6913 public static FingerPrint[] selectFingerPrints() {
6914 FingerPrint[] result = null;
6915 result = new FingerPrint[] { new TigerFingerPrint_BouncyCastle(),
6916 new SHA384FingerPrint_CryptixCrypto(),
6917 new HavalFingerPrint_Cryptix(),
6918 new RIPEMD128FingerPrint_FlexiCore(),
6919 new MD2FingerPrint_GNUCrypto(), new MD5FingerPrint_IAIK(),
6920 new Haval192_R4FingerPrint_Jacksum(),
6921 new RIPEMD160FingerPrint_JHBCI(),
6922 new SHA1FingerPrint_LogiCrypto(),
6923 new MD2FingerPrint_Mindbright(), new SHA256FingerPrint_SUN() };
6924 return result;
6925 }
6926
6927 /**
6928 * Muestra una forma (modo 1) sobre cómo seleccionar algoritmos
6929 * criptográficos de autentificación mediante huellas digitales con
6930 * especificación JCE
6931 *
6932 * @return Algoritmos criptográficos de autentificación mediante huellas
6933 * digitales con especificación JCE
6934 * @throws NoSuchAlgorithmException
6935 */
6936 public static MessageDigest[] selectFingerPrintsMode1_JCE()
6937 throws NoSuchAlgorithmException {
6938 MessageDigest[] result = null;
6939 result = new MessageDigest[] {
6940 MessageDigest.getInstance("Tiger", new BouncyCastleProvider()),
6941 MessageDigest.getInstance("SHA384", new CryptixCrypto()),
6942 MessageDigest.getInstance("Haval", new Cryptix()),
6943 MessageDigest.getInstance("RIPEMD128", new FlexiCoreProvider()),
6944 MessageDigest.getInstance("MD2", new GnuCrypto()),
6945 MessageDigest.getInstance("MD5", new IAIK()),
6946 MessageDigest.getInstance("RIPEMD160", new JHBCI()),
6947 MessageDigest.getInstance("SHA256", new Sun()) };
6948 return result;
6949 }
6950
6951 /**
6952 * Muestra una forma (modo 2) sobre cómo seleccionar algoritmos
6953 * criptográficos de autentificación mediante huellas digitales con
6954 * especificación JCE
6955 *
6956 * @return Algoritmos criptográficos de autentificación mediante huellas
6957 * digitales con especificación JCE
6958 * @throws NoSuchProviderException
6959 * @throws NoSuchAlgorithmException
6960 * @see Providers#registerProviders_JCE()
6961 */
6962 public static MessageDigest[] selectFingerPrintsMode2_JCE()
6963 throws NoSuchAlgorithmException, NoSuchProviderException {
6964 MessageDigest[] result = null;
6965 Providers.registerProviders_JCE();
6966 result = new MessageDigest[] {
6967 MessageDigest.getInstance("Tiger", "BC"),
6968 MessageDigest.getInstance("SHA384", "CryptixCrypto"),
6969 MessageDigest.getInstance("Haval", "Cryptix"),
6970 MessageDigest.getInstance("RIPEMD128", "FlexiCore"),
6971 MessageDigest.getInstance("MD2", "GNU-CRYPTO"),
6972 MessageDigest.getInstance("MD5", "IAIK"),
6973 MessageDigest.getInstance("RIPEMD160", "JHBCI"),
6974 MessageDigest.getInstance("SHA256", "SUN") };
6975 return result;
6976 }
6977
6978 /**
6979 * Muestra una forma (modo 3) sobre cómo seleccionar algoritmos
6980 * criptográficos de autentificación mediante huellas digitales con
6981 * especificación JCE
6982 *
6983 * @return Algoritmos criptográficos de autentificación mediante huellas
6984 * digitales con especificación JCE
6985 * @throws NoSuchAlgorithmException
6986 * @see Providers#registerProviders_JCE()
6987 */
6988 public static MessageDigest[] selectFingerPrintsMode3_JCE()
6989 throws NoSuchAlgorithmException {
6990 MessageDigest[] result = null;
6991 Providers.registerProviders_JCE();
6992 result = new MessageDigest[] { MessageDigest.getInstance("Tiger"),
6993 MessageDigest.getInstance("SHA384"),
6994 MessageDigest.getInstance("Haval"),
6995 MessageDigest.getInstance("RIPEMD128"),
6996 MessageDigest.getInstance("MD2"),
6997 MessageDigest.getInstance("MD5"),
6998 MessageDigest.getInstance("RIPEMD160"),
6999 MessageDigest.getInstance("SHA256") };
7000 return result;
7001 }
7002
7003 /**
7004 * Muestra cómo seleccionar algoritmos generadores de parámetros
7005 *
7006 * @return Algoritmos generadores de parámetros
7007 */
7008 public static ParameterGenerator[] selectParameterGenerators() {
7009 ParameterGenerator[] result = null;
7010 result = new ParameterGenerator[] {
7011 // new CAST6ParameterGenerator_BouncyCastle(),
7012 new RC5ParameterGenerator_FlexiCore(),
7013 new ECGFPParameterGenerator_FlexiEC(),
7014 new IQGQParameterGenerator_FlexiNF(),
7015 new KhazadParameterGenerator_GNUCrypto(),
7016 new AESParameterGenerator_IAIK(),
7017 new DSAParameterGenerator_SUN(),
7018 new RSAOAEPParameterGenerator_SunJCE() };
7019 return result;
7020 }
7021
7022 /**
7023 * Muestra una forma (modo 1) sobre cómo seleccionar algoritmos generadores
7024 * de parámetros con especificación JCE
7025 *
7026 * @return Algoritmos generadores de parámetros con especificación JCE
7027 * @throws NoSuchAlgorithmException
7028 */
7029 public static AlgorithmParameterGenerator[] selectParameterGeneratorsMode1_JCE()
7030 throws NoSuchAlgorithmException {
7031 AlgorithmParameterGenerator[] result = null;
7032 result = new AlgorithmParameterGenerator[] {
7033 AlgorithmParameterGenerator.getInstance("CAST6",
7034 new BouncyCastleProvider()),
7035 AlgorithmParameterGenerator.getInstance("RC5",
7036 new FlexiCoreProvider()),
7037 AlgorithmParameterGenerator.getInstance("ECGFP",
7038 new FlexiECProvider()),
7039 AlgorithmParameterGenerator.getInstance("IQGQ",
7040 new FlexiNFProvider()),
7041 AlgorithmParameterGenerator.getInstance("Rijndael", new IAIK()),
7042 AlgorithmParameterGenerator.getInstance("DSA", new Sun()),
7043 AlgorithmParameterGenerator.getInstance("OAEP", new SunJCE()) };
7044 return result;
7045 }
7046
7047 /**
7048 * Muestra una forma (modo 2) sobre cómo seleccionar algoritmos generadores
7049 * de parámetros con especificación JCE
7050 *
7051 * @return Algoritmos generadores de parámetros con especificación JCE
7052 * @throws NoSuchProviderException
7053 * @throws NoSuchAlgorithmException
7054 * @see Providers#registerProviders_JCE()
7055 */
7056 public static AlgorithmParameterGenerator[] selectParameterGeneratorsMode2_JCE()
7057 throws NoSuchAlgorithmException, NoSuchProviderException {
7058 AlgorithmParameterGenerator[] result = null;
7059 Providers.registerProviders_JCE();
7060 result = new AlgorithmParameterGenerator[] {
7061 AlgorithmParameterGenerator.getInstance("CAST6", "BC"),
7062 AlgorithmParameterGenerator.getInstance("RC5", "FlexiCore"),
7063 AlgorithmParameterGenerator.getInstance("ECGFP", "FlexiEC"),
7064 AlgorithmParameterGenerator.getInstance("IQGQ", "FlexiNF"),
7065 AlgorithmParameterGenerator.getInstance("Rijndael", "IAIK"),
7066 AlgorithmParameterGenerator.getInstance("DSA", "SUN"),
7067 AlgorithmParameterGenerator.getInstance("OAEP", "SunJCE") };
7068 return result;
7069 }
7070
7071 /**
7072 * Muestra una forma sobre (modo 3) cómo seleccionar algoritmos generadores
7073 * de parámetros con especificación JCE
7074 *
7075 * @return Algoritmos generadores de parámetros con especificación JCE
7076 * @throws NoSuchAlgorithmException
7077 * @see Providers#registerProviders_JCE()
7078 */
7079 public static AlgorithmParameterGenerator[] selectParameterGeneratorsMode3_JCE()
7080 throws NoSuchAlgorithmException {
7081 AlgorithmParameterGenerator[] result = null;
7082 Providers.registerProviders_JCE();
7083 result = new AlgorithmParameterGenerator[] {
7084 AlgorithmParameterGenerator.getInstance("CAST6"),
7085 AlgorithmParameterGenerator.getInstance("RC5"),
7086 AlgorithmParameterGenerator.getInstance("ECGFP"),
7087 AlgorithmParameterGenerator.getInstance("IQGQ"),
7088 AlgorithmParameterGenerator.getInstance("Rijndael"),
7089 AlgorithmParameterGenerator.getInstance("DSA"),
7090 AlgorithmParameterGenerator.getInstance("OAEP") };
7091 return result;
7092 }
7093
7094 /**
7095 * Muestra cómo seleccionar algoritmos traductores de parámetros
7096 *
7097 * @return Algoritmos traductores de parámetros
7098 */
7099 public static ParameterTranslator[] selectParameterTranslators() {
7100 ParameterTranslator[] result = null;
7101 result = new ParameterTranslator[] {
7102 new BlowfishParameterTranslator_BouncyCastle(),
7103 new RC2ParameterTranslator_FlexiCore(),
7104 new ECDSAParameterTranslator_FlexiEC(),
7105 new IQRDSAParameterTranslator_FlexiNF(),
7106 new AnubisParameterTranslator_GNUCrypto(),
7107 new RC4ParameterTranslator_IAIK(),
7108 new DSAParameterTranslator_SUN(),
7109 new RSAOAEPParameterTranslator_SunJCE() };
7110 return result;
7111 }
7112
7113 /**
7114 * Muestra una forma (modo 1) sobre cómo seleccionar algoritmos traductores
7115 * de parámetros con especificación JCE
7116 *
7117 * @return Algoritmos traductores de parámetros con especificación JCE
7118 * @throws NoSuchAlgorithmException
7119 */
7120 public static AlgorithmParameters[] selectParameterTranslatorsMode1_JCE()
7121 throws NoSuchAlgorithmException {
7122 AlgorithmParameters[] result = null;
7123 result = new AlgorithmParameters[] {
7124 AlgorithmParameters.getInstance("BLOWFISH",
7125 new BouncyCastleProvider()),
7126 AlgorithmParameters.getInstance("RC2", new FlexiCoreProvider()),
7127 AlgorithmParameters.getInstance("ECDSA", new FlexiECProvider()),
7128 AlgorithmParameters
7129 .getInstance("IQRDSA", new FlexiNFProvider()),
7130 AlgorithmParameters.getInstance("ANUBIS", new GnuCrypto()),
7131 AlgorithmParameters.getInstance("ARCFOUR", new IAIK()),
7132 AlgorithmParameters.getInstance("DSA", new Sun()),
7133 AlgorithmParameters.getInstance("OAEP", new SunJCE()) };
7134 return result;
7135 }
7136
7137 /**
7138 * Muestra una forma (modo 2) sobre cómo seleccionar algoritmos traductores
7139 * de parámetros con especificación JCE
7140 *
7141 * @return Algoritmos traductores de parámetros con especificación JCE
7142 * @throws NoSuchProviderException
7143 * @throws NoSuchAlgorithmException
7144 * @see Providers#registerProviders_JCE()
7145 */
7146 public static AlgorithmParameters[] selectParameterTranslatorsMode2_JCE()
7147 throws NoSuchAlgorithmException, NoSuchProviderException {
7148 AlgorithmParameters[] result = null;
7149 Providers.registerProviders_JCE();
7150 result = new AlgorithmParameters[] {
7151 AlgorithmParameters.getInstance("BLOWFISH", "BC"),
7152 AlgorithmParameters.getInstance("RC2", "FlexiCore"),
7153 AlgorithmParameters.getInstance("ECDSA", "FlexiEC"),
7154 AlgorithmParameters.getInstance("IQRDSA", "FlexiNF"),
7155 AlgorithmParameters.getInstance("ANUBIS", "GNU-CRYPTO"),
7156 AlgorithmParameters.getInstance("ARCFOUR", "IAIK"),
7157 AlgorithmParameters.getInstance("DSA", "SUN"),
7158 AlgorithmParameters.getInstance("OAEP", "SunJCE") };
7159 return result;
7160 }
7161
7162 /**
7163 * Muestra una forma (modo 3) sobre cómo seleccionar algoritmos traductores
7164 * de parámetros con especificación JCE
7165 *
7166 * @return Algoritmos traductores de parámetros con especificación JCE
7167 * @throws NoSuchAlgorithmException
7168 * @see Providers#registerProviders_JCE()
7169 */
7170 public static AlgorithmParameters[] selectParameterTranslatorsMode3_JCE()
7171 throws NoSuchAlgorithmException {
7172 AlgorithmParameters[] result = null;
7173 Providers.registerProviders_JCE();
7174 result = new AlgorithmParameters[] {
7175 AlgorithmParameters.getInstance("BLOWFISH"),
7176 AlgorithmParameters.getInstance("RC2"),
7177 AlgorithmParameters.getInstance("ECDSA"),
7178 AlgorithmParameters.getInstance("IQRDSA"),
7179 AlgorithmParameters.getInstance("ANUBIS"),
7180 AlgorithmParameters.getInstance("ARCFOUR"),
7181 AlgorithmParameters.getInstance("DSA"),
7182 AlgorithmParameters.getInstance("OAEP") };
7183 return result;
7184 }
7185
7186 /**
7187 * Muestra cómo seleccionar algoritmos criptográficos de protección basada
7188 * en contraseña
7189 *
7190 * @return Algoritmos criptográficos de protección basada en contraseña
7191 */
7192 public static PBEProtection[] selectPBEProtections() {
7193 PBEProtection[] result = null;
7194 result = new PBEProtection[] {
7195 new PBEwithMD5andAES128PBEProtection_BouncyCastle(),
7196 new PBEwithSHA1andTripleDES192PBEProtection_FlexiCore(),
7197 new PBEwithTigerandAnubisPBEProtection_GNUCrypto(),
7198 new PBEwithSHA1andTripleDES192PBEProtection_IAIK(),
7199 new PBEwithMD5andTripleDESPBEProtection_SunJCE() };
7200 return result;
7201 }
7202
7203 /**
7204 * Muestra una forma (modo 1) sobre cómo seleccionar algoritmos
7205 * criptográficos de protección basada en contraseña con especificación JCE
7206 *
7207 * @return Algoritmos criptográficos de protección basada en contraseña con
7208 * especificación JCE
7209 * @throws NoSuchPaddingException
7210 * @throws NoSuchAlgorithmException
7211 */
7212 public static Cipher[] selectPBEProtectionsMode1_JCE()
7213 throws NoSuchAlgorithmException, NoSuchPaddingException {
7214 Cipher[] result = null;
7215 result = new Cipher[] {
7216 Cipher.getInstance("PBEWITHMD5AND128BITAES-CBC-OPENSSL",
7217 new BouncyCastleProvider()),
7218 Cipher.getInstance("PbeWithSHAAnd3_KeyTripleDES_CBC",
7219 new FlexiCoreProvider()),
7220 Cipher
7221 .getInstance("PBEWithHMacTigerAndAnubis",
7222 new GnuCrypto()),
7223 Cipher.getInstance("PbeWithSHAAnd3_KeyTripleDES_CBC",
7224 new IAIK()),
7225 Cipher.getInstance("PBEwithMD5andDESede", new SunJCE()) };
7226 return result;
7227 }
7228
7229 /**
7230 * Muestra una forma (modo 2) sobre cómo seleccionar algoritmos
7231 * criptográficos de protección basada en contraseña con especificación JCE
7232 *
7233 * @return Algoritmos criptográficos de protección basada en contraseña con
7234 * especificación JCE
7235 * @throws NoSuchPaddingException
7236 * @throws NoSuchAlgorithmException
7237 * @throws NoSuchProviderException
7238 * @see Providers#registerProviders_JCE()
7239 */
7240 public static Cipher[] selectPBEProtectionsMode2_JCE()
7241 throws NoSuchAlgorithmException, NoSuchPaddingException,
7242 NoSuchProviderException {
7243 Cipher[] result = null;
7244 Providers.registerProviders_JCE();
7245 result = new Cipher[] {
7246 Cipher.getInstance("PBEWITHMD5AND128BITAES-CBC-OPENSSL", "BC"),
7247 Cipher.getInstance("PbeWithSHAAnd3_KeyTripleDES_CBC",
7248 "FlexiCore"),
7249 Cipher.getInstance("PBEWithHMacTigerAndAnubis", "GNU-CRYPTO"),
7250 Cipher.getInstance("PbeWithSHAAnd3_KeyTripleDES_CBC", "IAIK"),
7251 Cipher.getInstance("PBEwithMD5andDESede", "SunJCE") };
7252 return result;
7253 }
7254
7255 /**
7256 * Muestra una forma (modo 3) sobre cómo seleccionar algoritmos
7257 * criptográficos de protección basada en contraseña con especificación JCE
7258 *
7259 * @return Algoritmos criptográficos de protección basada en contraseña con
7260 * especificación JCE
7261 * @throws NoSuchPaddingException
7262 * @throws NoSuchAlgorithmException
7263 * @see Providers#registerProviders_JCE()
7264 */
7265 public static Cipher[] selectPBEProtectionsMode3_JCE()
7266 throws NoSuchAlgorithmException, NoSuchPaddingException {
7267 Cipher[] result = null;
7268 Providers.registerProviders_JCE();
7269 result = new Cipher[] {
7270 Cipher.getInstance("PBEWITHMD5AND128BITAES-CBC-OPENSSL"),
7271 Cipher.getInstance("PbeWithSHAAnd3_KeyTripleDES_CBC"),
7272 Cipher.getInstance("PBEWithHMacTigerAndAnubis"),
7273 Cipher.getInstance("PbeWithSHAAnd3_KeyTripleDES_CBC"),
7274 Cipher.getInstance("PBEwithMD5andDESede") };
7275 return result;
7276 }
7277
7278 /**
7279 * Muestra cómo seleccionar algoritmos generadores de datos aleatorios
7280 *
7281 * @return Algoritmos generadores de datos aleatorios
7282 */
7283 public static SecureRandomGenerator[] selectSecureRandomGenerators() {
7284 SecureRandomGenerator[] result = null;
7285 result = new SecureRandomGenerator[] {
7286 new BBSSecureRandomGenerator_FlexiCore(),
7287 new ECSecureRandomGenerator_FlexiEC(),
7288 new ICMSecureRandomGenerator_GNUCrypto(),
7289 new BlumBlumShubSecureRandomGenerator_Mindbright() };
7290 return result;
7291 }
7292
7293 /**
7294 * Muestra una forma (modo 1) sobre cómo seleccionar algoritmos generadores
7295 * de datos aleatorios con especificación JCE
7296 *
7297 * @return Algoritmos generadores de datos aleatorios con especificación JCE
7298 * @throws NoSuchAlgorithmException
7299 */
7300 public static SecureRandom[] selectSecureRandomGeneratorsMode1_JCE()
7301 throws NoSuchAlgorithmException {
7302 SecureRandom[] result = null;
7303 result = new SecureRandom[] {
7304 SecureRandom.getInstance("BBSRandom", new FlexiCoreProvider()),
7305 SecureRandom.getInstance("ECPRNG", new FlexiECProvider()),
7306 SecureRandom.getInstance("ICM", new GnuCrypto()), };
7307 return result;
7308 }
7309
7310 /**
7311 * Muestra una forma (modo 2) sobre cómo seleccionar algoritmos generadores
7312 * de datos aleatorios con especificación JCE
7313 *
7314 * @return Algoritmos generadores de datos aleatorios con especificación JCE
7315 * @throws NoSuchProviderException
7316 * @throws NoSuchAlgorithmException
7317 * @see Providers#registerProviders_JCE()
7318 */
7319 public static SecureRandom[] selectSecureRandomGeneratorsMode2_JCE()
7320 throws NoSuchAlgorithmException, NoSuchProviderException {
7321 SecureRandom[] result = null;
7322 Providers.registerProviders_JCE();
7323 result = new SecureRandom[] {
7324 SecureRandom.getInstance("BBSRandom", "FlexiCore"),
7325 SecureRandom.getInstance("ECPRNG", "FlexiEC"),
7326 SecureRandom.getInstance("ICM", "GNU-CRYPTO"), };
7327 return result;
7328 }
7329
7330 /**
7331 * Muestra una forma (modo 3) sobre cómo seleccionar algoritmos generadores
7332 * de datos aleatorios con especificación JCE
7333 *
7334 * @return Algoritmos generadores de datos aleatorios con especificación JCE
7335 * @throws NoSuchAlgorithmException
7336 * @see Providers#registerProviders_JCE()
7337 */
7338 public static SecureRandom[] selectSecureRandomGeneratorsMode3_JCE()
7339 throws NoSuchAlgorithmException {
7340 SecureRandom[] result = null;
7341 Providers.registerProviders_JCE();
7342 result = new SecureRandom[] { SecureRandom.getInstance("BBSRandom"),
7343 SecureRandom.getInstance("ECPRNG"),
7344 SecureRandom.getInstance("ICM"), };
7345 return result;
7346 }
7347
7348 /**
7349 * Muestra cómo seleccionar algoritmos criptográficos de protección
7350 * simétrica de flujo
7351 *
7352 * @return Algoritmos criptográficos de protección simétrica de flujo
7353 */
7354 public static StreamSymmetricProtection[] selectStreamSymmetricProtections() {
7355 StreamSymmetricProtection[] result = null;
7356 result = new StreamSymmetricProtection[] {
7357 new RC4StreamSymmetricProtection_BouncyCastle(),
7358 new RC4StreamSymmetricProtection_CryptixCrypto(),
7359 new RC4StreamSymmetricProtection_Cryptix(),
7360 new RC4StreamSymmetricProtection_GNUCrypto(),
7361 new RC4StreamSymmetricProtection_IAIK(),
7362 new RC4StreamSymmetricProtection_Mindbright(),
7363 new RC4StreamSymmetricProtection_SunJCE() };
7364 return result;
7365 }
7366
7367 /**
7368 * Muestra una forma (modo 1) sobre cómo seleccionar algoritmos
7369 * criptográficos de protección simétrica de flujo con especificación JCE
7370 *
7371 * @return Algoritmos criptográficos de protección simétrica de flujo con
7372 * especificación JCE
7373 * @throws NoSuchPaddingException
7374 * @throws NoSuchAlgorithmException
7375 */
7376 public static Cipher[] selectStreamSymmetricProtectionsMode1_JCE()
7377 throws NoSuchAlgorithmException, NoSuchPaddingException {
7378 Cipher[] result = null;
7379 result = new Cipher[] {
7380 Cipher.getInstance("ARC4", new BouncyCastleProvider()),
7381 Cipher.getInstance("RC4", new CryptixCrypto()),
7382 Cipher.getInstance("RC4", new Cryptix()),
7383 Cipher.getInstance("ARCFOUR", new GnuCrypto()),
7384 Cipher.getInstance("ARCFOUR", new IAIK()),
7385 Cipher.getInstance("RC4", new SunJCE()) };
7386 return result;
7387 }
7388
7389 /**
7390 * Muestra una forma (modo 2) sobre cómo seleccionar algoritmos
7391 * criptográficos de protección simétrica de flujo con especificación JCE
7392 *
7393 * @return Algoritmos criptográficos de protección simétrica de flujo con
7394 * especificación JCE
7395 * @throws NoSuchPaddingException
7396 * @throws NoSuchProviderException
7397 * @throws NoSuchAlgorithmException
7398 * @see Providers#registerProviders_JCE()
7399 */
7400 public static Cipher[] selectStreamSymmetricProtectionsMode2_JCE()
7401 throws NoSuchAlgorithmException, NoSuchProviderException,
7402 NoSuchPaddingException {
7403 Cipher[] result = null;
7404 Providers.registerProviders_JCE();
7405 result = new Cipher[] { Cipher.getInstance("ARC4", "BC"),
7406 Cipher.getInstance("RC4", "CryptixCrypto"),
7407 Cipher.getInstance("RC4", "Cryptix"),
7408 Cipher.getInstance("ARCFOUR", "GNU-CRYPTO"),
7409 Cipher.getInstance("ARCFOUR", "IAIK"),
7410 Cipher.getInstance("RC4", "SunJCE") };
7411 return result;
7412 }
7413
7414 /**
7415 * Muestra una forma (modo 3) sobre cómo seleccionar algoritmos
7416 * criptográficos de protección simétrica de flujo con especificación JCE
7417 *
7418 * @return Algoritmos criptográficos de protección simétrica de flujo con
7419 * especificación JCE
7420 * @throws NoSuchProviderException
7421 * @throws NoSuchPaddingException
7422 * @throws NoSuchAlgorithmException
7423 * @see Providers#registerProviders_JCE()
7424 */
7425 public static Cipher[] selectStreamSymmetricProtectionsMode3_JCE()
7426 throws NoSuchAlgorithmException, NoSuchPaddingException,
7427 NoSuchProviderException {
7428 Cipher[] result = null;
7429 Providers.registerProviders_JCE();
7430 result = new Cipher[] { Cipher.getInstance("ARC4"),
7431 Cipher.getInstance("RC4", "CryptixCrypto"),
7432 Cipher.getInstance("ARCFOUR", "GNU-CRYPTO"), };
7433 return result;
7434 }
7435
7436 /**
7437 * Muestra cómo seleccionar algoritmos generadores de claves simétricas
7438 *
7439 * @return Algoritmos generadores de claves simétricas
7440 */
7441 public static SymmetricKeyGenerator[] selectSymmetricKeyGenerators() {
7442 SymmetricKeyGenerator[] result = null;
7443 result = new SymmetricKeyGenerator[] {
7444 new CAST5SymmetricKeyGenerator_BouncyCastle(),
7445 new CAST5SymmetricKeyGenerator_CryptixCrypto(),
7446 new SquareSymmetricKeyGenerator_Cryptix(),
7447 new SaferPlusPlusSymmetricKeyGenerator_FlexiCore(),
7448 new KhazadSymmetricKeyGenerator_GNUCrypto(),
7449 new HmacRIPEMD128SymmetricKeyGenerator_IAIK(),
7450 new TripleDES128SymmetricKeyGenerator_JHBCI(),
7451 new BlowfishSymmetricKeyGenerator_LogiCrypto(),
7452 new DESSymmetricKeyGenerator_Mindbright(),
7453 new RC4SymmetricKeyGenerator_SunJCE() };
7454 return result;
7455 }
7456
7457 /**
7458 * Muestra una forma (modo 1) sobre cómo seleccionar algoritmos generadores
7459 * de claves simétricas con especificación JCE
7460 *
7461 * @return Algoritmos generadores de claves simétricas con especificación
7462 * JCE
7463 * @throws NoSuchAlgorithmException
7464 */
7465 public static javax.crypto.KeyGenerator[] selectSymmetricKeyGeneratorsMode1_JCE()
7466 throws NoSuchAlgorithmException {
7467 javax.crypto.KeyGenerator[] result = null;
7468 result = new javax.crypto.KeyGenerator[] {
7469 javax.crypto.KeyGenerator.getInstance("CAST5", new BouncyCastleProvider()),
7470 javax.crypto.KeyGenerator.getInstance("CAST5", new CryptixCrypto()),
7471 javax.crypto.KeyGenerator.getInstance("Square", new Cryptix()),
7472 javax.crypto.KeyGenerator.getInstance("SAFERPlusPlus",
7473 new FlexiCoreProvider()),
7474 javax.crypto.KeyGenerator.getInstance("HMAC/RIPEMD128", new IAIK()),
7475 javax.crypto.KeyGenerator.getInstance("DESede2Key", new JHBCI()),
7476 javax.crypto.KeyGenerator.getInstance("ARCFOUR", new SunJCE()) };
7477 return result;
7478 }
7479
7480 /**
7481 * Muestra una forma (modo 2) sobre cómo seleccionar algoritmos generadores
7482 * de claves simétricas con especificación JCE
7483 *
7484 * @return Algoritmos generadores de claves simétricas con especificación
7485 * JCE
7486 * @throws NoSuchProviderException
7487 * @throws NoSuchAlgorithmException
7488 * @see Providers#registerProviders_JCE()
7489 */
7490 public static javax.crypto.KeyGenerator[] selectSymmetricKeyGeneratorsMode2_JCE()
7491 throws NoSuchAlgorithmException, NoSuchProviderException {
7492 javax.crypto.KeyGenerator[] result = null;
7493 Providers.registerProviders_JCE();
7494 result = new javax.crypto.KeyGenerator[] { javax.crypto.KeyGenerator.getInstance("CAST5", "BC"),
7495 javax.crypto.KeyGenerator.getInstance("CAST5", "CryptixCrypto"),
7496 javax.crypto.KeyGenerator.getInstance("Square", "Cryptix"),
7497 javax.crypto.KeyGenerator.getInstance("SAFERPlusPlus", "FlexiCore"),
7498 javax.crypto.KeyGenerator.getInstance("HMAC/RIPEMD128", "IAIK"),
7499 javax.crypto.KeyGenerator.getInstance("DESede2Key", "JHBCI"),
7500 javax.crypto.KeyGenerator.getInstance("ARCFOUR", "SunJCE") };
7501 return result;
7502 }
7503
7504 /**
7505 * Muestra una forma (modo 3) sobre cómo seleccionar algoritmos generadores
7506 * de claves simétricas con especificación JCE
7507 *
7508 * @return Algoritmos generadores de claves simétricas con especificación
7509 * JCE
7510 * @throws NoSuchAlgorithmException
7511 * @see Providers#registerProviders_JCE()
7512 */
7513 public static javax.crypto.KeyGenerator[] selectSymmetricKeyGeneratorsMode3_JCE()
7514 throws NoSuchAlgorithmException {
7515 javax.crypto.KeyGenerator[] result = null;
7516 Providers.registerProviders_JCE();
7517 result = new javax.crypto.KeyGenerator[] { javax.crypto.KeyGenerator.getInstance("CAST5"),
7518 javax.crypto.KeyGenerator.getInstance("Square"),
7519 javax.crypto.KeyGenerator.getInstance("SAFERPlusPlus"),
7520 javax.crypto.KeyGenerator.getInstance("HMAC/RIPEMD128"),
7521 javax.crypto.KeyGenerator.getInstance("DESede2Key"),
7522 javax.crypto.KeyGenerator.getInstance("ARCFOUR") };
7523 return result;
7524 }
7525
7526 /**
7527 * Muestra cómo seleccionar algoritmos traductores de claves simétricas
7528 *
7529 * @return Algoritmos traductores de claves simétricas
7530 */
7531 public static SymmetricKeyTranslator[] selectSymmetricKeyTranslators() {
7532 SymmetricKeyTranslator[] result = null;
7533 result = new SymmetricKeyTranslator[] {
7534 new CamelliaSymmetricKeyTranslator_BouncyCastle(),
7535 new RC6SymmetricKeyTranslator_CryptixCrypto(),
7536 new RC2SymmetricKeyTranslator_Cryptix(),
7537 new SerpentSymmetricKeyTranslator_FlexiCore(),
7538 new AnubisSymmetricKeyTranslator_GNUCrypto(),
7539 new RC4SymmetricKeyTranslator_IAIK(),
7540 new TripleDES192SymmetricKeyTranslator_JHBCI(),
7541 new BlowfishSymmetricKeyTranslator_LogiCrypto(),
7542 new DESSymmetricKeyTranslator_Mindbright(),
7543 new PBEHmacSHA1SymmetricKeyTranslator_SunJCE() };
7544 return result;
7545 }
7546
7547 /**
7548 * Muestra una forma (modo 1) sobre cómo seleccionar algoritmos traductores
7549 * de claves simétricas con especificación JCE
7550 *
7551 * @return Algoritmos traductores de claves simétricas con especificación
7552 * JCE
7553 * @throws NoSuchAlgorithmException
7554 */
7555 public static SecretKeyFactory[] selectSymmetricKeyTranslatorsMode1_JCE()
7556 throws NoSuchAlgorithmException {
7557 SecretKeyFactory[] result = null;
7558 result = new SecretKeyFactory[] {
7559 SecretKeyFactory.getInstance("Camellia",
7560 new BouncyCastleProvider()),
7561 SecretKeyFactory
7562 .getInstance("Serpent", new FlexiCoreProvider()),
7563 SecretKeyFactory.getInstance("DESede3Key", new JHBCI()),
7564 SecretKeyFactory.getInstance("PBE", new SunJCE()) };
7565 return result;
7566 }
7567
7568 /**
7569 * Muestra una forma (modo 2) sobre cómo seleccionar algoritmos traductores
7570 * de claves simétricas con especificación JCE
7571 *
7572 * @return Algoritmos traductores de claves simétricas con especificación
7573 * JCE
7574 * @throws NoSuchProviderException
7575 * @throws NoSuchAlgorithmException
7576 * @see Providers#registerProviders_JCE()
7577 */
7578 public static SecretKeyFactory[] selectSymmetricKeyTranslatorsMode2_JCE()
7579 throws NoSuchAlgorithmException, NoSuchProviderException {
7580 SecretKeyFactory[] result = null;
7581 Providers.registerProviders_JCE();
7582 result = new SecretKeyFactory[] {
7583 SecretKeyFactory.getInstance("Camellia", "BC"),
7584 SecretKeyFactory.getInstance("Serpent", "FlexiCore"),
7585 SecretKeyFactory.getInstance("DESede3Key", "JHBCI"),
7586 SecretKeyFactory.getInstance("PBE", "SunJCE") };
7587 return result;
7588 }
7589
7590 /**
7591 * Muestra una forma (modo 3) sobre cómo seleccionar algoritmos traductores
7592 * de claves simétricas con especificación JCE
7593 *
7594 * @return Algoritmos traductores de claves simétricas con especificación
7595 * JCE
7596 * @throws NoSuchAlgorithmException
7597 * @see Providers#registerProviders_JCE()
7598 */
7599 public static SecretKeyFactory[] selectSymmetricKeyTranslatorsMode3_JCE()
7600 throws NoSuchAlgorithmException {
7601 SecretKeyFactory[] result = null;
7602 Providers.registerProviders_JCE();
7603 result = new SecretKeyFactory[] {
7604 SecretKeyFactory.getInstance("Camellia"),
7605 SecretKeyFactory.getInstance("Serpent"),
7606 SecretKeyFactory.getInstance("DESede3Key"),
7607 SecretKeyFactory.getInstance("PBE") };
7608 return result;
7609 }
7610
7611 }
7612
7613 /**
7614 * JCE y JCEF poseen ambas características únicas no compartidas.
7615 * <UL>
7616 * JCE proporciona características interesantes que no proporciona JCEF de
7617 * momento. Éstas son:
7618 * <LI>Protocolos de intercambio de claves (véase
7619 * {@link javax.crypto.KeyAgreement})</LI>
7620 * <LI>Gestión de certificados (véase {@link java.security.cert})</LI>
7621 * <LI>Almacenes de claves (véase {@link java.security.KeyStore})</LI>
7622 * </UL>
7623 * <UL>
7624 * Sin embargo, JCEF proporciona otras características muy interesantes que JCE
7625 * no suministra; además de mejorar enormemente el uso de JCE. Éstas son:
7626 * <LI>Algoritmos criptográficos compuestos. Véase:
7627 * {@link ComposedDigitalPBESeal_JCEFHelper}, {@link ComposedDigitalSignature_JCEFHelper},
7628 * {@link ComposedPBEProtection_JCEFHelper}, {@link GenericDigitalPBESeal_JCEFHelper},
7629 * {@link MacBlockSymmetricProtection_JCEFHelper}</LI>
7630 * <LI>Objetos seguros para cualquier algoritmo criptográfico (véase
7631 * {@link UsingSecureObject})</LI>
7632 * <LI>Flujos seguros para cualquier algoritmo criptográfico (véase
7633 * {@link UsingSecureStream})</LI>
7634 * <LI>Multitud de proveedores JCEF completos y fácil de usar (véase
7635 * {@link Providers})</LI>
7636 * <LI>Generadores de parámetros tales como: {@link Iv_ParameterGeneratorJCEFHelper},
7637 * {@link RC5_ParameterGeneratorJCEFHelper}, {@link PBEParameterGenerator})</LI>
7638 * <LI>Traductores de parámetros tales como: {@link Iv_ParameterTranslatorJCEFHelper},
7639 * {@link PBE_ParameterTranslatorJCEFHelper}, {@link RC5_ParameterTranslatorJCEFHelper}</LI>
7640 * <LI>Generadores de claves simétricas tales como:
7641 * {@link Basic_SymmetricKeyGeneratorJCEFHelper},
7642 * {@link PBE_SymmetricKeyGeneratorJCEFHelper}
7643 * <LI>Traductores de claves simétricas tales como:
7644 * {@link Basic_SymmetricKeyTranslatorJCEFHelper},
7645 * {@link PBE_SymmetricKeyTranslatorJCEFHelper}
7646 * </UL>
7647 */
7648 public static class SpecificFeatures {
7649 }
7650
7651 /**
7652 * <UL>
7653 * Para comprobar el correcto funcionamiento de los algoritmos, basta con
7654 * indicar un conjunto de casos de prueba con los valores de entrada deseados y
7655 * salida esperados sufientes. Cada entrada y salida es representada por clases
7656 * como:
7657 * <LI>{@link Algorithm_ImplementationTest}</LI>
7658 * <LI>{@link AsymmetricKeyGenerator_ImplementationTest}</LI>
7659 * <LI>{@link AsymmetricKeyTranslator_ImplementationTest}</LI>
7660 * <LI>{@link AsymmetricProtection_ImplementationTest}</LI>
7661 * <LI>{@link AuthenticationAlgorithm_ImplementationTest}</LI>
7662 * <LI>{@link BlockSymmetricProtection_ImplementationTest}</LI>
7663 * <LI>{@link CryptoAlgorithm_ImplementationTest}</LI>
7664 * <LI>{@link DigitalPBESeal_ImplementationTest}</LI>
7665 * <LI>{@link DigitalSeal_ImplementationTest}</LI>
7666 * <LI>{@link DigitalSignature_ImplementationTest}</LI>
7667 * <LI>{@link FingerPrint_ImplementationTest}</LI>
7668 * <LI>{@link Generator_ImplementationTest}</LI>
7669 * <LI>{@link KeyGenerator_ImplementationTest}</LI>
7670 * <LI>{@link KeyTranslator_ImplementationTest}</LI>
7671 * <LI>{@link ParameterGenerator_ImplementationTest}</LI>
7672 * <LI>{@link ParameterTranslator_ImplementationTest}</LI>
7673 * <LI>{@link PBEProtection_ImplementationTest}</LI>
7674 * <LI>{@link Protection_ImplementationTest}</LI>
7675 * <LI>{@link SecureRandomGenerator_ImplementationTest}</LI>
7676 * <LI>{@link StreamSymmetricProtection_ImplementationTest}</LI>
7677 * <LI>{@link SymmetricKeyGenerator_ImplementationTest}</LI>
7678 * <LI>{@link SymmetricKeyTranslator_ImplementationTest}</LI>
7679 * <LI>{@link SymmetricProtection_ImplementationTest}</LI>
7680 * <LI>{@link Translator_ImplementationTest}</LI>
7681 * </UL>
7682 * <UL>
7683 * De la comprobación del correcto funcionamiento de las implementaciones de los
7684 * algoritmos, se encargan las siguientes clases.:
7685 * <LI>{@link Algorithm_ImplementationTests}</LI>
7686 * <LI>{@link AsymmetricKeyGenerator_ImplementationTests}</LI>
7687 * <LI>{@link AsymmetricKeyTranslator_ImplementationTests}</LI>
7688 * <LI>{@link AsymmetricProtection_ImplementationTests}</LI>
7689 * <LI>{@link AuthenticationAlgorithm_ImplementationTests}</LI>
7690 * <LI>{@link BlockSymmetricProtection_ImplementationTests}</LI>
7691 * <LI>{@link CryptoAlgorithm_ImplementationTests}</LI>
7692 * <LI>{@link DigitalPBESeal_ImplementationTests}</LI>
7693 * <LI>{@link DigitalSeal_ImplementationTests}</LI>
7694 * <LI>{@link DigitalSignature_ImplementationTests}</LI>
7695 * <LI>{@link FingerPrint_ImplementationTests}</LI>
7696 * <LI>{@link Generator_ImplementationTests}</LI>
7697 * <LI>{@link KeyGenerator_ImplementationTests}</LI>
7698 * <LI>{@link KeyTranslator_ImplementationTests}</LI>
7699 * <LI>{@link ParameterGenerator_ImplementationTests}</LI>
7700 * <LI>{@link ParameterTranslator_ImplementationTests}</LI>
7701 * <LI>{@link PBEProtection_ImplementationTests}</LI>
7702 * <LI>{@link Protection_ImplementationTests}</LI>
7703 * <LI>{@link SecureRandomGenerator_ImplementationTests}</LI>
7704 * <LI>{@link StreamSymmetricProtection_ImplementationTests}</LI>
7705 * <LI>{@link SymmetricKeyGenerator_ImplementationTests}</LI>
7706 * <LI>{@link SymmetricKeyTranslator_ImplementationTests}</LI>
7707 * <LI>{@link SymmetricProtection_ImplementationTests}</LI>
7708 * <LI>{@link Translator_ImplementationTests}</LI>
7709 * </UL>
7710 */
7711 public static class TestAlgorithms {
7712 }
7713
7714 /**
7715 * <OL>
7716 * Para utilizar un algoritmo, es necesario realizar los siguientes pasos:
7717 * <LI>Seleccionar el algoritmo que se desea utilizar (véase
7718 * {@link SelectingAlgorithms})</LI>
7719 * <LI>De forma opcional, se puede configurar el algoritmo seleccionado (véase
7720 * {@link ConfiguratingAlgorithms})</LI>
7721 * <LI>Inicializar el algoritmo seleccionado (véase {@link Initiation})</LI>
7722 * <LI>Utilizar el algoritmo deseado tal y como se muestra aquí</LI>
7723 * </OL>
7724 * Aquí se muestra cómo se utiliza la autentificación y protección con JCE, es
7725 * decir, muestra cómo se generan y verifican autentificadores (huellas, sellos
7726 * y firmas digitales) y cómo se protegen y desprotegen datos.
7727 */
7728 public static class UsingAlgorithms {
7729
7730 /**
7731 * Mediante JCE, realiza conversiones entre las distintas representaciones
7732 * de las claves o parámetros
7733 *
7734 * @param algorithm
7735 * Algoritmo encargado de realizar la conversión
7736 * @param object
7737 * Clave o parámetro a convertir
7738 * @return Clave o parámetro convertido
7739 * @throws InvalidKeySpecException
7740 * Ocurre si no se ha podido realizar la operación
7741 * @throws IOException
7742 * Ocurre si no se ha podido realizar la operación
7743 * @throws InvalidParameterSpecException
7744 * Ocurre si no se ha podido realizar la operación
7745 */
7746 public static Object convert_JCE(Object algorithm, Object object)
7747 throws InvalidKeySpecException, InvalidParameterSpecException,
7748 IOException {
7749 Object result = null;
7750 if (algorithm instanceof KeyFactory) {
7751 result = convertKey_JCE(algorithm, object);
7752 } else if (algorithm instanceof SecretKeyFactory) {
7753 result = convertKey_JCE(algorithm, object);
7754 } else if (algorithm instanceof AlgorithmParameters) {
7755 result = convertParameter_JCE((AlgorithmParameters) algorithm,
7756 object);
7757 }
7758 return result;
7759 }
7760
7761 /**
7762 * Mediante JCE, realiza conversiones entre las distintas representaciones
7763 * de las claves/parámetros
7764 *
7765 * @param algorithm
7766 * Algoritmo de traducción
7767 * @param object
7768 * Clave/Parámetro a convertir
7769 * @return Clave/Parámetro convertido
7770 * @throws Throwable
7771 * Ocurre si no se ha podido realizar la operación
7772 */
7773 public static Object convert_JCEF(Translator algorithm, Object object)
7774 throws Throwable {
7775 Object result = null;
7776 if (algorithm instanceof KeyTranslator) {
7777 result = convertKey_JCEF((KeyTranslator) algorithm, object);
7778 } else if (algorithm instanceof ParameterTranslator) {
7779 result = convertParameter_JCEF((ParameterTranslator) algorithm,
7780 object);
7781 }
7782 return result;
7783 }
7784
7785 /**
7786 * Mediante JCE, realiza conversiones entre las distintas representaciones
7787 * de las claves asimétricas
7788 *
7789 * @param algorithm
7790 * Algoritmo de traducción de claves asimétricas
7791 * @param object
7792 * Clave asimétrica a convertir
7793 * @return Clave asimétrica convertida
7794 * @throws InvalidKeySpecException
7795 * Ocurre si no se ha podido realizar la operación
7796 */
7797 public static Object convertAsymmetricKey_JCE(KeyFactory algorithm,
7798 Object object) throws InvalidKeySpecException {
7799 Object result = null;
7800 if (object instanceof KeySpec) {
7801 result = algorithm.generatePrivate((KeySpec) object);
7802 if (result != null) {
7803 result = algorithm.generatePublic((KeySpec) object);
7804 }
7805 } else if (object instanceof PrivateKey) {
7806 result = algorithm
7807 .getKeySpec((PrivateKey) object, PrivateKey.class);
7808 } else if (object instanceof PublicKey) {
7809 result = algorithm.getKeySpec((PublicKey) object, PublicKey.class);
7810 }
7811 return result;
7812 }
7813
7814 /**
7815 * Mediante JCEF, realiza conversiones entre las distintas representaciones
7816 * de las claves asimétricas
7817 *
7818 * @param algorithm
7819 * Algoritmo de traducción de claves asimétricas
7820 * @param object
7821 * Clave asimétrica a convertir
7822 * @return Clave asimétrica convertida
7823 * @throws Throwable
7824 * Ocurre si no se ha podido realizar la operación
7825 * @see AsymmetricKeyTranslator#toPrivateKey(KeySpec)
7826 * @see AsymmetricKeyTranslator#toPrivateKeySpec(PrivateKey)
7827 * @see AsymmetricKeyTranslator#toPublicKey(KeySpec)
7828 * @see AsymmetricKeyTranslator#toPublicKeySpec(PublicKey)
7829 * @see AsymmetricKeyTranslator
7830 * @see #convertKey_JCEF(KeyTranslator, Object)
7831 */
7832 public static Object convertAsymmetricKey_JCEF(
7833 AsymmetricKeyTranslator algorithm, Object object) throws Throwable {
7834 Object result = null;
7835 if (object instanceof KeySpec) {
7836 result = algorithm.toPrivateKey((KeySpec) object);
7837 if (result != null) {
7838 result = algorithm.toPublicKey((KeySpec) object);
7839 }
7840 } else if (object instanceof PrivateKey) {
7841 result = algorithm.toPrivateKeySpec((PrivateKey) object);
7842 } else if (object instanceof PublicKey) {
7843 result = algorithm.toPublicKeySpec((PublicKey) object);
7844 }
7845 return result;
7846 }
7847
7848 /**
7849 * Mediante JCE, realiza conversiones entre las distintas representaciones
7850 * de las claves JCE
7851 *
7852 * @param algorithm
7853 * Algoritmo de traducción de claves
7854 * @param object
7855 * Clave a convertir
7856 * @return Clave convertida
7857 * @throws InvalidKeySpecException
7858 * Ocurre si no se ha podido realizar la operación
7859 */
7860 public static Object convertKey_JCE(Object algorithm, Object object)
7861 throws InvalidKeySpecException {
7862 Object result = null;
7863 if (algorithm instanceof KeyFactory) {
7864 result = convertAsymmetricKey_JCE((KeyFactory) algorithm, object);
7865 } else if (algorithm instanceof SecretKeyFactory) {
7866 result = convertSymmetricKey_JCE((SecretKeyFactory) algorithm,
7867 object);
7868 }
7869 return result;
7870 }
7871
7872 /**
7873 * Mediante JCEF, realiza conversiones entre las distintas representaciones
7874 * de las claves
7875 *
7876 * @param algorithm
7877 * Algoritmo de traducción de claves
7878 * @param object
7879 * Clave a convertir
7880 * @return Clave convertida
7881 * @throws Throwable
7882 * Ocurre si no se ha podido realizar la operación
7883 * @see KeyTranslator
7884 * @see #convertAsymmetricKey_JCEF(AsymmetricKeyTranslator, Object)
7885 * @see #convertSymmetricKey_JCEF(SymmetricKeyTranslator, Object)
7886 */
7887 public static Object convertKey_JCEF(KeyTranslator algorithm, Object object)
7888 throws Throwable {
7889 Object result = null;
7890 if (algorithm instanceof AsymmetricKeyTranslator) {
7891 result = convertAsymmetricKey_JCEF(
7892 (AsymmetricKeyTranslator) algorithm, object);
7893 } else if (algorithm instanceof SymmetricKeyTranslator) {
7894 result = convertSymmetricKey_JCEF(
7895 (SymmetricKeyTranslator) algorithm, object);
7896 }
7897 return result;
7898 }
7899
7900 /**
7901 * Mediante JCE, realiza conversiones JCE entre las distintas
7902 * representaciones de los parámetros
7903 *
7904 * @param algorithm
7905 * Algoritmo de traducción de parámetros
7906 * @param object
7907 * Parámetro a convertir
7908 * @return
7909 * @throws InvalidParameterSpecException
7910 * Ocurre si no se ha podido realizar la operación
7911 * @throws IOException
7912 * Ocurre si no se ha podido realizar la operación
7913 */
7914 public static Object convertParameter_JCE(AlgorithmParameters algorithm,
7915 Object object) throws InvalidParameterSpecException, IOException {
7916 Object result = null;
7917 if (object instanceof AlgorithmParameterSpec) {
7918 AlgorithmParameterSpec parameter = (AlgorithmParameterSpec) object;
7919 algorithm.init(parameter);
7920 result = algorithm.getEncoded();
7921 } else if (object instanceof byte[]) {
7922 byte[] parameter = (byte[]) object;
7923 algorithm.init(parameter);
7924 result = algorithm.getParameterSpec(AlgorithmParameterSpec.class);
7925 } else if (object instanceof Object[]) {
7926 Object[] objects = (Object[]) object;
7927 if (objects[0] instanceof AlgorithmParameterSpec) {
7928 AlgorithmParameterSpec parameter = (AlgorithmParameterSpec) objects[0];
7929 String format = (String) objects[1];
7930 algorithm.init(parameter);
7931 result = algorithm.getEncoded(format);
7932 } else if (objects[0] instanceof byte[]) {
7933 byte[] parameter = (byte[]) objects[0];
7934 String format = (String) objects[1];
7935 algorithm.init(parameter, format);
7936 result = algorithm
7937 .getParameterSpec(AlgorithmParameterSpec.class);
7938 }
7939 }
7940 return result;
7941 }
7942
7943 /**
7944 * Mediante JCEF, realiza conversiones entre las distintas representaciones
7945 * de los parámetros
7946 *
7947 * @param algorithm
7948 * Algoritmo de traducción de parámetros
7949 * @param object
7950 * Parámetro a convertir
7951 * @return Parámetro convertido
7952 * @throws Throwable
7953 * Ocurre si no se ha podido realizar la operación
7954 * @see ParameterTranslator#toParameter(AlgorithmParameterSpec, String)
7955 * @see ParameterTranslator#toParameter(byte[], String)
7956 * @see ParameterTranslator
7957 * @see #convert_JCEF(Translator, Object)
7958 */
7959 public static Object convertParameter_JCEF(ParameterTranslator algorithm,
7960 Object object) throws Throwable {
7961 Object result = null;
7962 if (object instanceof AlgorithmParameterSpec) {
7963 AlgorithmParameterSpec parameter = (AlgorithmParameterSpec) object;
7964 String format = null;
7965 result = algorithm.toParameter(parameter, format);
7966 } else if (object instanceof byte[]) {
7967 byte[] parameter = (byte[]) object;
7968 String format = null;
7969 result = algorithm.toParameter(parameter, format);
7970 } else if (object instanceof Object[]) {
7971 Object[] objects = (Object[]) object;
7972 if (objects[0] instanceof AlgorithmParameterSpec) {
7973 AlgorithmParameterSpec parameter = (AlgorithmParameterSpec) objects[0];
7974 String format = (String) objects[1];
7975 result = algorithm.toParameter(parameter, format);
7976 } else if (objects[0] instanceof byte[]) {
7977 byte[] parameter = (byte[]) objects[0];
7978 String format = (String) objects[1];
7979 result = algorithm.toParameter(parameter, format);
7980 }
7981 }
7982 return result;
7983 }
7984
7985 /**
7986 * Mediante JCE, realiza conversiones entre las distintas representaciones
7987 * de las claves simétricas
7988 *
7989 * @param algorithm
7990 * Algoritmo de traducción de claves simétricas
7991 * @param object
7992 * Clave simétrica a convertir
7993 * @return Clave simétrica convertida
7994 * @throws InvalidKeySpecException
7995 * Ocurre si no se ha podido realizar la operación
7996 */
7997 public static Object convertSymmetricKey_JCE(SecretKeyFactory algorithm,
7998 Object object) throws InvalidKeySpecException {
7999 Object result = null;
8000 if (object instanceof KeySpec) {
8001 result = algorithm.generateSecret((KeySpec) object);
8002 } else if (object instanceof SecretKey) {
8003 result = algorithm.getKeySpec((SecretKey) object, KeySpec.class);
8004 }
8005 return result;
8006 }
8007
8008 /**
8009 * Mediante JCEF, realiza conversiones entre las distintas representaciones
8010 * de las claves simétricas
8011 *
8012 * @param algorithm
8013 * Algoritmo de traducción de claves simétricas
8014 * @param object
8015 * Clave simétrica a convertir
8016 * @return Clave simétrica convertida
8017 * @throws Throwable
8018 * Ocurre si no se ha podido realizar la operación
8019 * @see SymmetricKeyTranslator#toSymmetricKey(KeySpec)
8020 * @see SymmetricKeyTranslator#toSymmetricKeySpec(SecretKey)
8021 * @see SymmetricKeyTranslator
8022 * @see #convertKey_JCEF(KeyTranslator, Object)
8023 */
8024 public static Object convertSymmetricKey_JCEF(
8025 SymmetricKeyTranslator algorithm, Object object) throws Throwable {
8026 Object result = null;
8027 if (object instanceof KeySpec) {
8028 result = algorithm.toSymmetricKey((KeySpec) object);
8029 } else if (object instanceof SecretKey) {
8030 result = algorithm.toSymmetricKeySpec((SecretKey) object);
8031 }
8032 return result;
8033 }
8034
8035 /**
8036 * Mediante JCE, genera claves, parámetros o datos aleatorios
8037 *
8038 * @param algorithm
8039 * Algoritmo generador
8040 * @return Clave, parámetro o datos aleatorios generados
8041 * @throws InvalidParameterSpecException
8042 * Ocurre si no se ha podido realizar la operación
8043 */
8044 public static Object generate_JCE(Object algorithm)
8045 throws InvalidParameterSpecException {
8046 Object result = null;
8047 if (algorithm instanceof KeyPairGenerator) {
8048 result = generateKey_JCE(algorithm);
8049 } else if (algorithm instanceof javax.crypto.KeyGenerator) {
8050 result = generateKey_JCE(algorithm);
8051 } else if (algorithm instanceof AlgorithmParameterGenerator) {
8052 result = generateParameter_JCE((AlgorithmParameterGenerator) algorithm);
8053 } else if (algorithm instanceof SecureRandom) {
8054 result = generateRandom_JCE((SecureRandom) algorithm);
8055 }
8056 return result;
8057 }
8058
8059 /**
8060 * Mediante JCEF, genera claves, parámetros o datos aleatorios
8061 *
8062 * @param algorithm
8063 * Algoritmo generador
8064 * @return Clave, parámetro o datos aleatorios generados
8065 * @throws Throwable
8066 * Ocurre si no se ha podido realizar la operación
8067 * @see Generator
8068 * @see #generateKey_JCEF(KeyGenerator)
8069 * @see #generateParameter_JCEF(ParameterGenerator)
8070 * @see #generateRandom_JCEF(SecureRandomGenerator)
8071 */
8072 public static Object generate_JCEF(Generator algorithm) throws Throwable {
8073 Object result = null;
8074 if (algorithm instanceof KeyGenerator) {
8075 result = generateKey_JCEF((KeyGenerator) algorithm);
8076 } else if (algorithm instanceof ParameterGenerator) {
8077 result = generateParameter_JCEF((ParameterGenerator) algorithm);
8078 } else if (algorithm instanceof SecureRandomGenerator) {
8079 result = generateRandom_JCEF((SecureRandomGenerator) algorithm);
8080 }
8081 return result;
8082 }
8083
8084 /**
8085 * Mediante JCE, genera una pareja de claves asimétricas
8086 *
8087 * @param algorithm
8088 * Algoritmo generador de parejas de claves asimétricas
8089 * @return Pareja de claves asimétricas generada
8090 */
8091 public static Object generateAsymmetricKey_JCE(KeyPairGenerator algorithm) {
8092 KeyPair result = null;
8093 result = algorithm.generateKeyPair();
8094 return result;
8095 }
8096
8097 /**
8098 * Mediante JCEF, genera una pareja de claves asimétricas
8099 *
8100 * @param algorithm
8101 * Algoritmo generador de parejas de claves asimétricas
8102 * @return Pareja de claves asimétricas generada
8103 * @throws Throwable
8104 * Ocurre si no se ha podido realizar la operación
8105 * @see AsymmetricKeyGenerator#generateAsymmetricKeys()
8106 * @see AsymmetricKeyGenerator
8107 * @see #generateKey_JCEF(KeyGenerator)
8108 */
8109 public static Object generateAsymmetricKey_JCEF(
8110 AsymmetricKeyGenerator algorithm) throws Throwable {
8111 KeyPair result = null;
8112 result = algorithm.generateAsymmetricKeys();
8113 return result;
8114 }
8115
8116 /**
8117 * Mediante JCE, genera el autentificador de unos datos
8118 *
8119 * @param algorithm
8120 * Algoritmo para generar el autentificador de los datos
8121 * @return Autentificador de los datos
8122 * @throws Throwable
8123 * @see #generateFingerPrint_JCE(MessageDigest, byte[][])
8124 * @see #generateDigitalSeal_JCE(Mac, byte[][])
8125 * @see #generateDigitalSignature_JCE(Signature, byte[][])
8126 */
8127 public static byte[] generateAuthenticator_JCE(Object algorithm,
8128 byte[][] data) throws Throwable {
8129 byte[] result = null;
8130 if (algorithm instanceof MessageDigest) {
8131 result = generateFingerPrint_JCE((MessageDigest) algorithm, data);
8132 } else if (algorithm instanceof Mac) {
8133 result = generateDigitalSeal_JCE((Mac) algorithm, data);
8134 } else if (algorithm instanceof Signature) {
8135 result = generateDigitalSignature_JCE((Signature) algorithm, data);
8136 }
8137 return result;
8138 }
8139
8140 /**
8141 * Mediante JCEF, genera un autentificador mediante un algoritmo
8142 * criptográfico de autentificación
8143 * <UL>
8144 * <LI>Para el suministro del conjunto de datos, del cual se va a generar
8145 * su autentificador, se invoca de forma iterativa el método:</LI>
8146 * <UL>
8147 * <LI>{@link CryptoAlgorithm#secure(byte[])}</LI>
8148 * </UL>
8149 * <LI>Una vez suministrados todos los datos, se genera el autentificador
8150 * mediante</LI>
8151 * <UL>
8152 * <LI>{@link CryptoAlgorithm#secure()}</LI>
8153 * </UL>
8154 * <LI>NOTA: Estos métodos son heredados por la clase
8155 * AuthenticationAlgorithm</LI>
8156 * <LI>Por otro lado, estos son los únicos métodos necesarios para generar
8157 * autentificadores, ya sean huellas, sellos o firmas digitales</LI>
8158 * </UL>
8159 *
8160 * @param algorithm
8161 * Algoritmo de autentificación utilizado para generar el
8162 * autentificador
8163 * @param data
8164 * Conjunto de datos del cual se va a generar el autentificador
8165 * @return Autentificador
8166 * @throws Throwable
8167 * Ocurre si no se ha podido realizar la operación
8168 * @see CryptoAlgorithm#secure(byte[])
8169 * @see CryptoAlgorithm#secure()
8170 * @see AuthenticationAlgorithm
8171 * @see #secureData_JCEF(CryptoAlgorithm, byte[][])
8172 * @see #generateFingerPrint_JCEF(FingerPrint, byte[][])
8173 * @see #generateDigitalSeal_JCEF(DigitalSeal, byte[][])
8174 * @see #generateDigitalSignature_JCEF(DigitalSignature, byte[][])
8175 */
8176 public static byte[] generateAuthenticator_JCEF(
8177 AuthenticationAlgorithm algorithm, byte[][] data) throws Throwable {
8178 byte[] result = null;
8179 result = secureData_JCEF(algorithm, data);
8180 return result;
8181 }
8182
8183 /**
8184 * Mediante JCE, genera el sello digital de unos datos utilizando un
8185 * algoritmo criptográfico de autentificación mediante sellos digitales
8186 * basado en contraseña
8187 *
8188 * @param algorithm
8189 * @param data
8190 * @return
8191 * @throws Throwable
8192 */
8193 public static byte[] generateDigitalPBESeal_JCE(Mac algorithm, byte[][] data)
8194 throws Throwable {
8195 return generateAuthenticator_JCE(algorithm, data);
8196 }
8197
8198 /**
8199 * Mediante JCEF, genera el sello digital de unos datos utilizando un
8200 * algoritmo criptográfico de autentificación mediante sellos digitales
8201 * basado en contraseña
8202 *
8203 * @param algorithm
8204 * Algoritmo criptográfico de autentificación mediante sellos
8205 * digitales basado en contraseña
8206 * @param data
8207 * Datos
8208 * @return Sello digital basado en contraseña
8209 * @throws Throwable
8210 * Ocurre si no se ha podido realizar la operación
8211 * @see DigitalPBESeal
8212 * @see #generateAuthenticator_JCEF(AuthenticationAlgorithm, byte[][])
8213 */
8214 public static byte[] generateDigitalPBESeal_JCEF(DigitalPBESeal algorithm,
8215 byte[][] data) throws Throwable {
8216 return generateAuthenticator_JCEF(algorithm, data);
8217 }
8218
8219 /**
8220 * Mediante JCE, genera sellos digitales
8221 *
8222 * <UL>
8223 * Para generar sellos digitales en JCE, se han de realizan las siguientes
8224 * fases:
8225 * <LI>Para el suministro de datos se emplean:
8226 * <UL>
8227 * <LI>{@link Mac#update(byte)}</LI>
8228 * <LI>{@link Mac#update(byte[])}</LI>
8229 * <LI>{@link Mac#update(byte[], int, int)}</LI>
8230 * <LI>{@link Mac#update(java.nio.ByteBuffer)}</LI>
8231 * </UL>
8232 * </LI>
8233 * <LI>Para el suministro de datos y generar el mac:
8234 * <UL>
8235 * <LI>{@link Mac#doFinal(byte[])}</LI>
8236 * </UL>
8237 * </LI>
8238 * <LI>Para generar el mac:
8239 * <UL>
8240 * <LI>{@link Mac#doFinal()}</LI>
8241 * <LI>{@link Mac#doFinal(byte[], int)}</LI>
8242 * </UL>
8243 * </LI>
8244 * <LI>Los únicos métodos imprescindibles son:
8245 * <UL>
8246 * <LI>{@link Mac#update(byte[])}</LI>
8247 * <LI>{@link Mac#doFinal()}</LI>
8248 * </UL>
8249 * </LI>
8250 * </UL>
8251 *
8252 * @see #generateAuthenticator_JCE(Object, byte[][])
8253 */
8254 public static byte[] generateDigitalSeal_JCE(Mac algorithm, byte[][] data) {
8255 byte[] result = null;
8256 for (int i = 0; data != null && i < data.length; i++) {
8257 algorithm.update(data[i]);
8258 }
8259 result = algorithm.doFinal();
8260 return result;
8261 }
8262
8263 /**
8264 * Mediante JCEF, genera el sello digital de unos datos utilizando un
8265 * algoritmo criptográfico de autentificación mediante sellos digitales
8266 *
8267 * @param algorithm
8268 * Algoritmo criptográfico de autentificación mediante sellos
8269 * digitales
8270 * @param data
8271 * Datos
8272 * @return Sello digital
8273 * @throws Throwable
8274 * Ocurre si no se ha podido realizar la operación
8275 * @see DigitalSeal
8276 * @see #generateAuthenticator_JCEF(AuthenticationAlgorithm, byte[][])
8277 */
8278 public static byte[] generateDigitalSeal_JCEF(DigitalSeal algorithm,
8279 byte[][] data) throws Throwable {
8280 return generateAuthenticator_JCEF(algorithm, data);
8281 }
8282
8283 /**
8284 * Mediante JCE, genera firmas digitales
8285 * <UL>
8286 * Para generar firmas digitales en JCE, se han de realizan las siguientes
8287 * fases:
8288 * <LI>Para el suministro de datos se emplean:
8289 * <UL>
8290 * <LI>{@link Signature#update(byte)}</LI>
8291 * <LI>{@link Signature#update(byte[])}</LI>
8292 * <LI>{@link Signature#update(byte[], int, int)}</LI>
8293 * <LI>{@link Signature#update(java.nio.ByteBuffer)}</LI>
8294 * </UL>
8295 * </LI>
8296 * <LI>Para generar la firma digital:
8297 * <UL>
8298 * <LI>{@link Signature#sign()}</LI>
8299 * <LI>{@link Signature#sign(byte[], int, int)}</LI>
8300 * </UL>
8301 * </LI>
8302 * <LI>Los únicos métodos imprescindibles son:
8303 * <UL>
8304 * <LI>{@link Signature#update(byte[])}</LI>
8305 * <LI>{@link Signature#sign()}</LI>
8306 * </UL>
8307 * </LI>
8308 * </UL>
8309 *
8310 * @see #generateAuthenticator_JCE(Object, byte[][])
8311 */
8312 public static byte[] generateDigitalSignature_JCE(Signature algorithm,
8313 byte[][] data) throws SignatureException {
8314 byte[] result = null;
8315 for (int i = 0; data != null && i < data.length; i++) {
8316 algorithm.update(data[i]);
8317 }
8318 result = algorithm.sign();
8319 return result;
8320 }
8321
8322 /**
8323 * Mediante JCEF, genera la firma digital de unos datos utilizando un
8324 * algoritmo criptográfico de autentificación mediante firmas digitales
8325 *
8326 * @param algorithm
8327 * Algoritmo criptográfico de autentificación mediante firmas
8328 * digitales
8329 * @param data
8330 * Datos
8331 * @return Firma digital
8332 * @throws Throwable
8333 * Ocurre si no se ha podido realizar la operación
8334 * @see DigitalSignature
8335 * @see #generateAuthenticator_JCEF(AuthenticationAlgorithm, byte[][])
8336 */
8337 public static byte[] generateDigitalSignature_JCEF(
8338 DigitalSignature algorithm, byte[][] data) throws Throwable {
8339 return generateAuthenticator_JCEF(algorithm, data);
8340 }
8341
8342 /**
8343 * Mediante JCE, genera huellas digitales
8344 * <UL>
8345 * <LI>Para el suministro de datos
8346 * <UL>
8347 * <LI>{@link MessageDigest#update(byte)}</LI>
8348 * <LI>{@link MessageDigest#update(byte[])}</LI>
8349 * <LI>{@link MessageDigest#update(byte[], int, int)}</LI>
8350 * <LI>{@link MessageDigest#update(java.nio.ByteBuffer)}</LI>
8351 * </UL>
8352 * </LI>
8353 * <LI>Para el suministro de datos y generación del resumen:
8354 * <UL>
8355 * <LI>{@link MessageDigest#digest(byte[])</LI>
8356 * </UL>
8357 * </LI>
8358 * <LI>Para generar el resumen:
8359 * <UL>
8360 * <LI>{@link MessageDigest#digest()}</LI>
8361 * <LI>{@link MessageDigest#digest(byte[], int, int)}</LI>
8362 * </UL>
8363 * </LI>
8364 * <LI>Los únicos métodos imprescindibles son:
8365 * <UL>
8366 * <LI>{@link MessageDigest#update(byte[])}</LI>
8367 * <LI>{@link MessageDigest#digest()}</LI>
8368 * </UL>
8369 * </LI>
8370 * </UL>
8371 *
8372 * @param algorithm
8373 * @param data
8374 * @return
8375 * @see #generateAuthenticator_JCE(Object, byte[][])
8376 */
8377 public static byte[] generateFingerPrint_JCE(MessageDigest algorithm,
8378 byte[][] data) {
8379 byte[] result = null;
8380 for (int i = 0; data != null && i < data.length; i++) {
8381 algorithm.update(data[i]);
8382 }
8383 result = algorithm.digest();
8384 return result;
8385 }
8386
8387 /**
8388 * Mediante JCEF, genera la huella digital de unos datos utilizando un
8389 * algoritmo criptográfico de autentificación mediante huellas digitales
8390 *
8391 * @param algorithm
8392 * Algoritmo criptográfico de autentificación mediante huellas
8393 * digitales
8394 * @param data
8395 * Datos
8396 * @return Huella digital
8397 * @throws Throwable
8398 * Ocurre si no se ha podido realizar la operación
8399 * @see FingerPrint
8400 * @see #generateAuthenticator_JCEF(AuthenticationAlgorithm, byte[][])
8401 */
8402 public static byte[] generateFingerPrint_JCEF(FingerPrint algorithm,
8403 byte[][] data) throws Throwable {
8404 return generateAuthenticator_JCEF(algorithm, data);
8405 }
8406
8407 /**
8408 * Mediante JCE, genera claves
8409 *
8410 * @param algorithm
8411 * Generador de claves
8412 * @return Clave generada
8413 */
8414 public static Object generateKey_JCE(Object algorithm) {
8415 Object result = null;
8416 if (algorithm instanceof KeyPairGenerator) {
8417 result = generateAsymmetricKey_JCE((KeyPairGenerator) algorithm);
8418 } else if (algorithm instanceof javax.crypto.KeyGenerator) {
8419 result = generateSymmetricKey_JCE((javax.crypto.KeyGenerator) algorithm);
8420 }
8421 return result;
8422 }
8423
8424 /**
8425 * Mediante JCEF, genera claves
8426 *
8427 * @param algorithm
8428 * Generador de claves
8429 * @return Clave generada
8430 * @throws Throwable
8431 * Ocurre si no se ha podido realizar la operación
8432 * @see #generateAsymmetricKey_JCEF(AsymmetricKeyGenerator)
8433 * @see #generateSymmetricKey_JCEF(SymmetricKeyGenerator)
8434 * @see KeyGenerator
8435 * @see #generate_JCEF(Generator)
8436 */
8437 public static Object generateKey_JCEF(KeyGenerator algorithm)
8438 throws Throwable {
8439 Object result = null;
8440 if (algorithm instanceof AsymmetricKeyGenerator) {
8441 result = generateAsymmetricKey_JCEF((AsymmetricKeyGenerator) algorithm);
8442 } else if (algorithm instanceof SymmetricKeyGenerator) {
8443 result = generateSymmetricKey_JCEF((SymmetricKeyGenerator) algorithm);
8444 }
8445 return result;
8446 }
8447
8448 /**
8449 * Mediante JCE, genera un parámetro
8450 *
8451 * @param algorithm
8452 * Algoritmo generador de parámetros
8453 * @return Parámetro generado
8454 * @throws InvalidParameterSpecException
8455 * Ocurre si no se ha podido realizar la operación
8456 */
8457 public static Object generateParameter_JCE(
8458 AlgorithmParameterGenerator algorithm)
8459 throws InvalidParameterSpecException {
8460 AlgorithmParameterSpec result = null;
8461 result = algorithm.generateParameters().getParameterSpec(
8462 AlgorithmParameterSpec.class);
8463 return result;
8464 }
8465
8466 /**
8467 * Mediante JCEF, genera un parámetro
8468 *
8469 * @param algorithm
8470 * Algoritmo generador de parámetros
8471 * @return Parámetro generado
8472 * @throws Throwable
8473 * Ocurre si no se ha podido realizar la operación
8474 * @see ParameterGenerator#generateParameter()
8475 * @see ParameterGenerator
8476 * @see #generate_JCEF(Generator)
8477 */
8478 public static Object generateParameter_JCEF(ParameterGenerator algorithm)
8479 throws Throwable {
8480 AlgorithmParameterSpec result = null;
8481 result = algorithm.generateParameter();
8482 return result;
8483 }
8484
8485 /**
8486 * Mediante JCE, genera datos aleatorios
8487 *
8488 * @param algorithm
8489 * Algoritmo generador de datos aleatorios
8490 * @return Datos aleatorios generados
8491 */
8492 public static Object generateRandom_JCE(SecureRandom algorithm) {
8493 SecureRandom result = null;
8494 result = algorithm;
8495 return result;
8496 }
8497
8498 /**
8499 * Mediante JCEF, genera datos aleatorios
8500 *
8501 * @param algorithm
8502 * Algoritmo generador de datos aleatorios
8503 * @return Datos aleatorios generados
8504 * @throws Throwable
8505 * @see SecureRandomGenerator#generateRandom()
8506 * @see SecureRandomGenerator
8507 * @see #generate_JCEF(Generator)
8508 */
8509 public static Object generateRandom_JCEF(SecureRandomGenerator algorithm)
8510 throws Throwable {
8511 SecureRandom result = null;
8512 result = algorithm.generateRandom();
8513 return result;
8514 }
8515
8516 /**
8517 * Mediante JCE, genera una clave simétrica
8518 *
8519 * @param algorithm
8520 * Generador de claves simétricas
8521 * @return Clave simétrica generada
8522 */
8523 public static Object generateSymmetricKey_JCE(
8524 javax.crypto.KeyGenerator algorithm) {
8525 SecretKey result = null;
8526 result = algorithm.generateKey();
8527 return result;
8528 }
8529
8530 /**
8531 * Mediante JCEF, genera una clave simétrica
8532 *
8533 * @param algorithm
8534 * Generador de claves simétricas
8535 * @return Clave simétrica generada
8536 * @throws Throwable
8537 * Ocurre si no se ha podido realizar la operación
8538 * @see SymmetricKeyGenerator#generateSymmetricKey()
8539 * @see SymmetricKeyGenerator
8540 * @see #generateKey_JCEF(KeyGenerator)
8541 */
8542 public static Object generateSymmetricKey_JCEF(
8543 SymmetricKeyGenerator algorithm) throws Throwable {
8544 SecretKey result = null;
8545 result = algorithm.generateSymmetricKey();
8546 return result;
8547 }
8548
8549 /**
8550 * Mediante JCE, protege datos
8551 *
8552 * <UL>
8553 * Para proteger datos es necesario realizar las siguientes etapas:
8554 * <LI>Antes de nada, es necesario inicializar el algoritmo de protección
8555 * <LI>Para proporcionar un conjunto de datos suministrándolo uno a uno, se
8556 * utilizan los siguientes métodos:
8557 * <UL>
8558 * <LI>{@link javax.crypto.Cipher#update(byte[])}</LI>
8559 * <LI>{@link javax.crypto.Cipher#update(byte[], int, int)}</LI>
8560 * <LI>{@link javax.crypto.Cipher#update(byte[], int, int, byte[])}</LI>
8561 * <LI>{@link javax.crypto.Cipher#update(byte[], int, int, byte[], int)}</LI>
8562 * <LI>{@link javax.crypto.Cipher#update(java.nio.ByteBuffer, java.nio.ByteBuffer)}</LI>
8563 * </UL>
8564 * </LI>
8565 * <LI>Para finalizar este proceso, indicando los últimos datos, se
8566 * utilizan:
8567 * <UL>
8568 * <LI>{@link javax.crypto.Cipher#doFinal(byte[])}</LI>
8569 * <LI>{@link javax.crypto.Cipher.doFinal(output: byte[], offset: int) : int;</LI>
8570 * <LI>{@link javax.crypto.Cipher.doFinal(data: byte[], offset: int, length: int) :
8571 * byte[];</LI>
8572 * <LI>{@link javax.crypto.Cipher.doFinal(data: byte[], offset: int, length:
8573 * int, output: byte[]) : int;</LI>
8574 * <LI>{@link javax.crypto.Cipher.doFinal(data: byte[], offset: int,
8575 * length: int, output: byte[], offsetOutput: int): int;</LI>
8576 * <LI>{@link javax.crypto.Cipher.doFinal(data: java.nio.ByteBuffer, output:
8577 * java.nio.ByteBuffer) : int;</LI>
8578 * </UL>
8579 * </LI>
8580 * <LI>Para finalizar este proceso se utiliza:
8581 * <UL>
8582 * <LI>{@link javax.crypto.Cipher#doFinal()}</LI>
8583 * </UL>
8584 * </LI>
8585 * <LI>Los únicos métodos básicos son:
8586 * <UL>
8587 * <LI>javax.crypto.Cipher.update(data: byte[]) : byte[];</LI>
8588 * <LI>javax.crypto.Cipher.doFinal() : byte[];</LI>
8589 * </UL>
8590 * </LI>
8591 * </UL>
8592 *
8593 * @param algorithm
8594 * Algoritmo criptográfico de protección
8595 * @param data
8596 * Datos a proteger
8597 * @return Datos protegidos
8598 * @throws BadPaddingException
8599 * Ocurre si no se ha podido realizar la operación
8600 * @throws IllegalBlockSizeException
8601 * Ocurre si no se ha podido realizar la operación
8602 */
8603 public static byte[] protectData_JCE(Cipher algorithm, byte[][] data)
8604 throws IllegalBlockSizeException, BadPaddingException {
8605 byte[] result = null;
8606 byte[] tempresult = null;
8607 for (int i = 0; data != null && i < data.length; i++) {
8608 tempresult = algorithm.update(data[i]);
8609 if (tempresult != null) {
8610 result = ArrayUtils.addAll(result, tempresult);
8611 }
8612 }
8613 tempresult = algorithm.doFinal();
8614 if (tempresult != null) {
8615 result = ArrayUtils.addAll(result, tempresult);
8616 }
8617 return result;
8618 }
8619
8620 /**
8621 * Mediante JCEF, Se protegen unos datos utilizando un algoritmo
8622 * criptográfico de protección
8623 * <UL>
8624 * <LI>Para el suministro del conjunto de datos, los cuales se van a
8625 * proteger paso a paso, se invoca de forma iterativa el método:
8626 * {@link CryptoAlgorithm#secure(byte[])}</LI>
8627 * <LI>Una vez suministrados todos los datos, se obtienen los datos
8628 * protegidos mediante: {@link CryptoAlgorithm#secure()}</LI>
8629 * <LI>Por otro lado, estos son los únicos métodos necesarios para proteger
8630 * datos, independientemente de que se tratase de algoritmos protección
8631 * simétrica o asimétrica</LI>
8632 * <LI>También cabe destacar, que si los datos son demasiados, es necesario
8633 * utilizar el método siguiente para poder ir guardando fuera de la memoria
8634 * los datos que ya han sido protegidos; y para ello se utiliza el método:
8635 * {@link Protection#getResult()}</LI>
8636 * </UL>
8637 *
8638 * @param algorithm
8639 * Algoritmo criptográfico de protección
8640 * @param data
8641 * Datos
8642 * @return Datos protegidos
8643 * @throws Throwable
8644 * Ocurre si no se ha podido realizar la operación
8645 * @see Protection
8646 * @see #secureData_JCEF(CryptoAlgorithm, byte[][])
8647 */
8648 public static byte[] protectData_JCEF(Protection algorithm, byte[][] data)
8649 throws Throwable {
8650 byte[] result = null;
8651 result = secureData_JCEF((CryptoAlgorithm) algorithm, data);
8652 return result;
8653 }
8654
8655 /**
8656 * Mediante JCEF, se protegen unos datos utilizando un algoritmo
8657 * criptográfico de protección asimétrica
8658 *
8659 * @param algorithm
8660 * Algoritmo criptográfico de protección asimétrica
8661 * @param data
8662 * Datos
8663 * @return Datos protegidos
8664 * @throws Throwable
8665 * Ocurre si no se ha podido realizar la operación
8666 * @see AsymmetricProtection
8667 * @see #protectData_JCEF(Protection, byte[][])
8668 */
8669 public static byte[] protectData_JCEF(AsymmetricProtection algorithm,
8670 byte[][] data) throws Throwable {
8671 byte[] result = null;
8672 result = protectData_JCEF((Protection) algorithm, data);
8673 return result;
8674 }
8675
8676 /**
8677 * Mediante JCEF, se protegen unos datos utilizando un algoritmo
8678 * criptográfico de protección simétrica de bloques
8679 *
8680 * @param algorithm
8681 * Algoritmo criptográfico de protección simétrica de bloques
8682 * @param data
8683 * Datos
8684 * @return Datos protegidos
8685 * @throws Throwable
8686 * Ocurre si no se ha podido realizar la operación
8687 * @see BlockSymmetricProtection
8688 * @see #protectData_JCEF(SymmetricProtection, byte[][])
8689 */
8690 public static byte[] protectData_JCEF(BlockSymmetricProtection algorithm,
8691 byte[][] data) throws Throwable {
8692 byte[] result = null;
8693 result = protectData_JCEF((SymmetricProtection) algorithm, data);
8694 return result;
8695 }
8696
8697 /**
8698 * Mediante JCEF, se protegen unos datos utilizando un algoritmo
8699 * criptográfico de protección basada en contraseña
8700 *
8701 * @param algorithm
8702 * Algoritmo criptográfico de protección basada en contraseña
8703 * @param data
8704 * Datos
8705 * @return Datos protegidos
8706 * @throws Throwable
8707 * Ocurre si no se ha podido realizar la operación
8708 * @see PBEProtection
8709 * @see #protectData_JCEF(SymmetricProtection, byte[][])
8710 */
8711 public static byte[] protectData_JCEF(PBEProtection algorithm, byte[][] data)
8712 throws Throwable {
8713 byte[] result = null;
8714 result = protectData_JCEF((SymmetricProtection) algorithm, data);
8715 return result;
8716 }
8717
8718 /**
8719 * Mediante JCEF, se protegen unos datos utilizando un algoritmo
8720 * criptográfico de protección simétrica de flujo
8721 *
8722 * @param algorithm
8723 * Algoritmo criptográfico de protección simétrica de flujo
8724 * @param data
8725 * Datos
8726 * @return Datos protegidos
8727 * @throws Throwable
8728 * Ocurre si no se ha podido realizar la operación
8729 * @see BlockSymmetricProtection
8730 * @see #protectData_JCEF(SymmetricProtection, byte[][])
8731 */
8732 public static byte[] protectData_JCEF(StreamSymmetricProtection algorithm,
8733 byte[][] data) throws Throwable {
8734 byte[] result = null;
8735 result = protectData_JCEF((SymmetricProtection) algorithm, data);
8736 return result;
8737 }
8738
8739 /**
8740 * Mediante JCEF, se protegen unos datos utilizando un algoritmo
8741 * criptográfico de protección simétrica
8742 *
8743 * @param algorithm
8744 * Algoritmo criptográfico de protección simétrica
8745 * @param data
8746 * Datos
8747 * @return Datos protegidos
8748 * @throws Throwable
8749 * Ocurre si no se ha podido realizar la operación
8750 * @see SymmetricProtection
8751 * @see #protectData_JCEF(Protection, byte[][])
8752 */
8753 public static byte[] protectData_JCEF(SymmetricProtection algorithm,
8754 byte[][] data) throws Throwable {
8755 byte[] result = null;
8756 result = protectData_JCEF((Protection) algorithm, data);
8757 return result;
8758 }
8759
8760 /**
8761 * Mediante JCE, asegura datos mediante un algoritmo criptográfico
8762 *
8763 * @param algorithm
8764 * Algoritmo criptográfico
8765 * @param data
8766 * Datos a asegurar
8767 * @return Datos asegurados
8768 * @throws Throwable
8769 * Ocurre si no se ha podido realizar la operación
8770 */
8771 public static byte[] secureData_JCE(Object algorithm, byte[][] data)
8772 throws Throwable {
8773 byte[] result = null;
8774 if (algorithm instanceof MessageDigest) {
8775 result = generateFingerPrint_JCE((MessageDigest) algorithm, data);
8776 } else if (algorithm instanceof Mac) {
8777 result = generateDigitalSeal_JCE((Mac) algorithm, data);
8778 } else if (algorithm instanceof Signature) {
8779 result = generateDigitalSignature_JCE((Signature) algorithm, data);
8780 } else if (algorithm instanceof Cipher) {
8781 result = protectData_JCE((Cipher) algorithm, data);
8782 }
8783 return result;
8784 }
8785
8786 /**
8787 * Mediante JCEF, asegura datos mediante un algoritmo criptográfico
8788 * <UL>
8789 * <LI>Para asegurar un conjunto de datos, éstos se suministran de forma
8790 * iterativa a través de {@link CryptoAlgorithm#secure(byte[])}</LI>
8791 * <LI>Finalmente, para terminar de aplicar el proceso de seguridad, se
8792 * debe llamar a {@link CryptoAlgorithm#secure()}</LI>
8793 * <LI>El método de finalización {@link CryptoAlgorithm#secure()} devuelve
8794 * el autentificador de los datos si se trata de un algoritmo de
8795 * autentificación, o los datos protegidos si se tratara de un algoritmo de
8796 * protección</LI>
8797 * <LI></LI>
8798 * </UL>
8799 *
8800 * @param algorithm
8801 * Algoritmo criptográfico
8802 * @param data
8803 * Datos a asegurar
8804 * @return Datos asegurados
8805 * @throws Throwable
8806 * Ocurre si no se ha podido realizar la operación
8807 * @see CryptoAlgorithm#secure(byte[])
8808 * @see CryptoAlgorithm#secure()
8809 * @see CryptoAlgorithm
8810 * @see #protectData_JCEF(Protection, byte[][])
8811 * @see #generateAuthenticator_JCEF(AuthenticationAlgorithm, byte[][])
8812 */
8813 public static byte[] secureData_JCEF(CryptoAlgorithm algorithm,
8814 byte[][] data) throws Throwable {
8815 byte[] result = null;
8816 for (int i = 0; data != null && i < data.length; i++) {
8817 algorithm.secure(data[i]);
8818 }
8819 result = algorithm.secure();
8820 return result;
8821 }
8822
8823 /**
8824 * Mediante JCE, traduce claves o parámetros desconocid@s en claves o
8825 * parámetros conocid@s
8826 *
8827 * @param algorithm
8828 * Algoritmo de traducción
8829 * @param object
8830 * Clave/parámetro desconocid@
8831 * @return Clave/parámetro conocid@
8832 * @throws InvalidKeyException
8833 * Ocurre si no se ha podido realizar la operación
8834 */
8835 public static Object translate_JCE(Object algorithm, Object object)
8836 throws InvalidKeyException {
8837 Object result = null;
8838 if (algorithm instanceof AlgorithmParameters) {
8839 result = translateParameter_JCE((AlgorithmParameters) algorithm,
8840 (AlgorithmParameterSpec) object);
8841 } else if (algorithm instanceof KeyFactory) {
8842 result = translateAsymmetricKey_JCE((KeyFactory) algorithm, object);
8843 } else if (algorithm instanceof SecretKeyFactory) {
8844 result = translateSymmetricKey_JCE((SecretKeyFactory) algorithm,
8845 object);
8846 }
8847 return result;
8848 }
8849
8850 /**
8851 * Mediante JCEF, traduce claves/parámetros desconocid@s en
8852 * claves/parámetros conocid@s
8853 *
8854 * @param algorithm
8855 * Algoritmo de traducción
8856 * @param object
8857 * Clave/parámetro desconocid@
8858 * @return Clave/parámetro conocid@
8859 * @throws Throwable
8860 * Ocurre si no se ha podido realizar la operación
8861 * @see Translator
8862 * @see #translateKey_JCEF(KeyTranslator, Object)
8863 * @see #translateParameter_JCEF(ParameterTranslator,
8864 * AlgorithmParameterSpec)
8865 */
8866 public static Object translate_JCEF(Translator algorithm, Object object)
8867 throws Throwable {
8868 Object result = null;
8869 if (algorithm instanceof KeyTranslator) {
8870 result = translateKey_JCEF((KeyTranslator) algorithm, object);
8871 } else if (algorithm instanceof ParameterTranslator) {
8872 result = translateParameter_JCEF((ParameterTranslator) algorithm,
8873 (AlgorithmParameterSpec) object);
8874 }
8875 return result;
8876 }
8877
8878 /**
8879 * Mediante JCEF, traduce claves asimétricas privadas/públicas desconocidas
8880 * en claves asimétricas privadas/públicas conocidas
8881 *
8882 * @param algorithm
8883 * Algoritmo de traducción de claves asimétricas
8884 * @param object
8885 * Clave asimétrica privada/pública desconocida
8886 * @return Clave asimétrica privada/pública conocida
8887 * @throws InvalidKeyException
8888 * Ocurre si no se ha podido realizar la operación
8889 */
8890 public static Object translateAsymmetricKey_JCE(KeyFactory algorithm,
8891 Object object) throws InvalidKeyException {
8892 Object result = null;
8893 result = algorithm.translateKey((Key) object);
8894 return result;
8895 }
8896
8897 /**
8898 * Mediante JCEF, Traduce claves asimétricas privadas/públicas desconocidas
8899 * en claves asimétricas privadas/públicas conocidas
8900 *
8901 * @param algorithm
8902 * Algoritmo de traducción de claves asimétricas
8903 * @param object
8904 * Clave asimétrica privada/pública desconocida
8905 * @return Clave asimétrica privada/pública conocida
8906 * @throws Throwable
8907 * Ocurre si no se ha podido realizar la operación
8908 * @see AsymmetricKeyTranslator#toPrivateKey(PrivateKey)
8909 * @see AsymmetricKeyTranslator#toPublicKey(PublicKey)
8910 * @see AsymmetricKeyTranslator
8911 * @see #translateKey_JCEF(KeyTranslator, Object)
8912 */
8913 public static Object translateAsymmetricKey_JCEF(
8914 AsymmetricKeyTranslator algorithm, Object object) throws Throwable {
8915 Object result = null;
8916 if (object instanceof PrivateKey) {
8917 result = algorithm.toPrivateKey((PrivateKey) object);
8918 } else if (object instanceof PublicKey) {
8919 result = algorithm.toPublicKey((PublicKey) object);
8920 }
8921 return result;
8922 }
8923
8924 /**
8925 * Mediante JCE, traduce claves desconocidas en claves conocidas
8926 *
8927 * @param algorithm
8928 * Algoritmo de traducción de claves
8929 * @param object
8930 * Clave desconocida
8931 * @return Clave conocida
8932 * @throws InvalidKeyException
8933 * Ocurre si no se ha podido realizar la operación
8934 */
8935 public static Object translateKey_JCE(Object algorithm, Object object)
8936 throws InvalidKeyException {
8937 Object result = null;
8938 if (algorithm instanceof KeyFactory) {
8939 result = translateAsymmetricKey_JCE((KeyFactory) algorithm, object);
8940 } else if (algorithm instanceof SecretKeyFactory) {
8941 translateSymmetricKey_JCE((SecretKeyFactory) algorithm, object);
8942 }
8943 return result;
8944 }
8945
8946 /**
8947 * Mediante JCEF, traduce claves desconocidas en claves conocidas
8948 *
8949 * @param algorithm
8950 * Algoritmo de traducción de claves
8951 * @param object
8952 * Clave desconocida
8953 * @return Clave conocida
8954 * @throws Throwable
8955 * Ocurre si no se ha podido realizar la operación
8956 * @see KeyTranslator
8957 * @see #translateAsymmetricKey_JCEF(AsymmetricKeyTranslator, Object)
8958 * @see #translateSymmetricKey_JCEF(SymmetricKeyTranslator, Object)
8959 */
8960 public static Object translateKey_JCEF(KeyTranslator algorithm,
8961 Object object) throws Throwable {
8962 Object result = null;
8963 if (algorithm instanceof AsymmetricKeyTranslator) {
8964 result = translateAsymmetricKey_JCEF(
8965 (AsymmetricKeyTranslator) algorithm, object);
8966 } else if (algorithm instanceof SymmetricKeyTranslator) {
8967 translateSymmetricKey_JCEF((SymmetricKeyTranslator) algorithm,
8968 object);
8969 }
8970 return result;
8971 }
8972
8973 /**
8974 * Mediante JCE, traduce parámetros desconocidos en parámetros conocidos
8975 *
8976 * @param algorithm
8977 * Algoritmo de traducción de parámetros
8978 * @param parameter
8979 * Parámetro desconocido
8980 * @return Parámetro conocido
8981 */
8982 public static AlgorithmParameterSpec translateParameter_JCE(
8983 AlgorithmParameters algorithm, AlgorithmParameterSpec parameter) {
8984 AlgorithmParameterSpec result = null;
8985 result = parameter;
8986 return result;
8987 }
8988
8989 /**
8990 * Traduce parámetros desconocidos en parámetros conocidos
8991 *
8992 * @param algorithm
8993 * Algoritmo de traducción de parámetros
8994 * @param parameter
8995 * Parámetro desconocido
8996 * @return Parámetro conocido
8997 * @see ParameterTranslator
8998 * @see #translate_JCEF(Translator, Object)
8999 */
9000 public static AlgorithmParameterSpec translateParameter_JCEF(
9001 ParameterTranslator algorithm, AlgorithmParameterSpec parameter) {
9002 AlgorithmParameterSpec result = null;
9003 result = parameter;
9004 return result;
9005 }
9006
9007 /**
9008 * Mediante JCE, traduce una clave simétrica Acepta claves desconocidas,
9009 * conocidos en forma Spec y forma transparente
9010 *
9011 * @param algorithm
9012 * Algoritmo de traducción de claves simétricas
9013 * @param object
9014 * Clave simétrica desconocida
9015 * @return Clave simétrica conocida
9016 * @throws InvalidKeyException
9017 * Ocurre si no se ha podido realizar la operación
9018 */
9019 public static Object translateSymmetricKey_JCE(SecretKeyFactory algorithm,
9020 Object object) throws InvalidKeyException {
9021 SecretKey result = null;
9022 if (object instanceof SecretKey) {
9023 result = algorithm.translateKey((SecretKey) object);
9024 }
9025 return result;
9026 }
9027
9028 /**
9029 * Mediante JCEF, traduce claves simétricas desconocidas en claves
9030 * simétricas conocidas
9031 *
9032 * @param algorithm
9033 * Algoritmo de traducción de claves simétricas
9034 * @param symmetricKey
9035 * Clave simétrica desconocida
9036 * @return Clave simétrica conocida
9037 * @throws Throwable
9038 * Ocurre si no se ha podido realizar la operación
9039 * @see SymmetricKeyTranslator#toSymmetricKey(SecretKey)
9040 * @see SymmetricKeyTranslator
9041 * @see #translateKey_JCEF(KeyTranslator, Object)
9042 */
9043 public static SecretKey translateSymmetricKey_JCEF(
9044 SymmetricKeyTranslator algorithm, Object object) throws Throwable {
9045 SecretKey result = null;
9046 if (object instanceof SecretKey) {
9047 result = algorithm.toSymmetricKey((SecretKey) object);
9048 }
9049 return result;
9050 }
9051
9052 /**
9053 * Mediante JCE, desprotege datos
9054 * <UL>
9055 * Para desproteger datos es necesario realizar las siguientes etapas:
9056 * <LI>Antes de nada, es necesario inicializar el algoritmo de protección
9057 * <LI>Para proporcionar un conjunto de datos suministrándolo uno a uno, se
9058 * utilizan los siguientes métodos:
9059 * <UL>
9060 * <LI>{@link javax.crypto.Cipher#update(byte[])}</LI>
9061 * <LI>{@link javax.crypto.Cipher#update(byte[], int, int)}</LI>
9062 * <LI>{@link javax.crypto.Cipher#update(byte[], int, int, byte[])}</LI>
9063 * <LI>{@link javax.crypto.Cipher#update(byte[], int, int, byte[], int)}</LI>
9064 * <LI>{@link javax.crypto.Cipher#update(java.nio.ByteBuffer, java.nio.ByteBuffer)}</LI>
9065 * </UL>
9066 * </LI>
9067 * <LI>Para finalizar este proceso, indicando los últimos datos, se
9068 * utilizan:
9069 * <UL>
9070 * <LI>{@link javax.crypto.Cipher#doFinal(byte[])}</LI>
9071 * <LI>{@link javax.crypto.Cipher.doFinal(output: byte[], offset: int) : int;</LI>
9072 * <LI>{@link javax.crypto.Cipher.doFinal(data: byte[], offset: int, length: int) :
9073 * byte[];</LI>
9074 * <LI>{@link javax.crypto.Cipher.doFinal(data: byte[], offset: int, length:
9075 * int, output: byte[]) : int;</LI>
9076 * <LI>{@link javax.crypto.Cipher.doFinal(data: byte[], offset: int,
9077 * length: int, output: byte[], offsetOutput: int): int;</LI>
9078 * <LI>{@link javax.crypto.Cipher.doFinal(data: java.nio.ByteBuffer, output:
9079 * java.nio.ByteBuffer) : int;</LI>
9080 * </UL>
9081 * </LI>
9082 * <LI>Para finalizar este proceso se utiliza:
9083 * <UL>
9084 * <LI>{@link javax.crypto.Cipher#doFinal()}</LI>
9085 * </UL>
9086 * </LI>
9087 * <LI>Los únicos métodos básicos son:
9088 * <UL>
9089 * <LI>javax.crypto.Cipher.update(data: byte[]) : byte[];</LI>
9090 * <LI>javax.crypto.Cipher.doFinal() : byte[];</LI>
9091 * </UL>
9092 * </LI>
9093 * </UL>
9094 *
9095 * @param algorithm
9096 * Algoritmo criptográfico de protección
9097 * @param data
9098 * Datos protegidos
9099 * @return Datos desprotegidos
9100 * @throws BadPaddingException
9101 * Ocurre si no se ha podido realizar la operación
9102 * @throws IllegalBlockSizeException
9103 * Ocurre si no se ha podido realizar la operación
9104 */
9105 public static byte[] unprotectData_JCE(Cipher algorithm, byte[][] data)
9106 throws IllegalBlockSizeException, BadPaddingException {
9107 byte[] result = null;
9108 byte[] tempresult = null;
9109 for (int i = 0; data != null && i < data.length; i++) {
9110 tempresult = algorithm.update(data[i]);
9111 if (tempresult != null) {
9112 result = ArrayUtils.addAll(result, tempresult);
9113 }
9114 }
9115 tempresult = algorithm.doFinal();
9116 if (tempresult != null) {
9117 result = ArrayUtils.addAll(result, tempresult);
9118 }
9119 return result;
9120 }
9121
9122 /**
9123 * Mediante JCEF, se desprotegen unos datos protegidos utilizando un
9124 * algoritmo criptográfico de protección
9125 * <UL>
9126 * <LI>Para el suministro del conjunto de datos, los cuales se van a
9127 * proteger paso a paso, se invoca de forma iterativa el método
9128 * {@link CryptoAlgorithm#unsecure(byte[])}</LI>
9129 * <LI>Una vez suministrados todos los datos, se obtienen los datos
9130 * protegidos mediante {@link Protection#unsecure()}</LI>
9131 * <LI>Por otro lado, estos son los únicos métodos necesarios para
9132 * desproteger datos, independientemente de que se tratase de algoritmos
9133 * protección simétrica o asimétrica</LI>
9134 * <LI>También cabe destacar, que si los datos son demasiados, es necesario
9135 * utilizar el método {@link Protection#getResult()} para poder ir guardando
9136 * fuera de la memoria los datos que ya han sido desprotegidos</LI>
9137 * </UL>
9138 *
9139 * @param algorithm
9140 * Algoritmo criptográfico de protección
9141 * @param data
9142 * Datos protegidos
9143 * @return Datos desprotegidos
9144 * @throws Throwable
9145 * Ocurre si no se ha podido realizar la operación
9146 * @see Protection
9147 * @see #unsecureData_JCEF(CryptoAlgorithm, byte[][])
9148 */
9149 public static byte[] unprotectData_JCEF(Protection algorithm, byte[][] data)
9150 throws Throwable {
9151 byte[] result = null;
9152 for (int i = 0; data != null && i < data.length; i++) {
9153 algorithm.unsecure(data[i]);
9154 }
9155 result = algorithm.unsecure();
9156 return result;
9157 }
9158
9159 /**
9160 * Mediante JCEF, se desprotegen unos datos protegidos utilizando un
9161 * algoritmo criptográfico de protección asimétrica
9162 *
9163 * @param algorithm
9164 * Algoritmo criptográfico de protección asimétrica
9165 * @param data
9166 * Datos protegidos
9167 * @return Datos desprotegidos
9168 * @throws Throwable
9169 * Ocurre si no se ha podido realizar la operación
9170 * @see AsymmetricProtection
9171 * @see #unprotectData_JCEF(Protection, byte[][])
9172 */
9173 public static byte[] unprotectData_JCEF(AsymmetricProtection algorithm,
9174 byte[][] data) throws Throwable {
9175 byte[] result = null;
9176 result = unprotectData_JCEF((Protection) algorithm, data);
9177 return result;
9178 }
9179
9180 /**
9181 * Mediante JCEF, se desprotegen unos datos protegidos utilizando un
9182 * algoritmo criptográfico de protección simétrica de bloques
9183 *
9184 * @param algorithm
9185 * Algoritmo criptográfico de protección simétrica de bloques
9186 * @param data
9187 * Datos protegidos
9188 * @return Datos desprotegidos
9189 * @throws Throwable
9190 * Ocurre si no se ha podido realizar la operación
9191 * @see BlockSymmetricProtection
9192 * @see #unprotectData_JCEF(SymmetricProtection, byte[][])
9193 */
9194 public static byte[] unprotectData_JCEF(BlockSymmetricProtection algorithm,
9195 byte[][] data) throws Throwable {
9196 byte[] result = null;
9197 result = unprotectData_JCEF((SymmetricProtection) algorithm, data);
9198 return result;
9199 }
9200
9201 /**
9202 * Mediante JCEF, se desprotegen unos datos protegidos utilizando un
9203 * algoritmo criptográfico de protección basada en contraseña
9204 *
9205 * @param algorithm
9206 * Algoritmo criptográfico de protección basada en contraseña
9207 * @param data
9208 * Datos protegidos
9209 * @return Datos desprotegidos
9210 * @throws Throwable
9211 * Ocurre si no se ha podido realizar la operación
9212 * @see PBESymmetricProtection
9213 * @see #unprotectData_JCEF(SymmetricProtection, byte[][])
9214 */
9215 public static byte[] unprotectData_JCEF(PBEProtection algorithm,
9216 byte[][] data) throws Throwable {
9217 byte[] result = null;
9218 result = unprotectData_JCEF((SymmetricProtection) algorithm, data);
9219 return result;
9220 }
9221
9222 /**
9223 * Mediante JCEF, se desprotegen unos datos protegidos utilizando un
9224 * algoritmo criptográfico de protección simétrica de flujo
9225 *
9226 * @param algorithm
9227 * Algoritmo criptográfico de protección simétrica de flujo
9228 * @param data
9229 * Datos protegidos
9230 * @return Datos desprotegidos
9231 * @throws Throwable
9232 * Ocurre si no se ha podido realizar la operación
9233 * @see StreamSymmetricProtection
9234 * @see #unprotectData_JCEF(SymmetricProtection, byte[][])
9235 */
9236 public static byte[] unprotectData_JCEF(
9237 StreamSymmetricProtection algorithm, byte[][] data)
9238 throws Throwable {
9239 byte[] result = null;
9240 result = unprotectData_JCEF((SymmetricProtection) algorithm, data);
9241 return result;
9242 }
9243
9244 /**
9245 * Mediante JCEF, se desprotegen unos datos protegidos utilizando un
9246 * algoritmo criptográfico de protección simétrica
9247 *
9248 * @param algorithm
9249 * Algoritmo criptográfico de protección simétrica
9250 * @param data
9251 * Datos protegidos
9252 * @return Datos desprotegidos
9253 * @throws Throwable
9254 * Ocurre si no se ha podido realizar la operación
9255 * @see SymmetricProtection
9256 * @see #unprotectData_JCEF(Protection, byte[][])
9257 */
9258 public static byte[] unprotectData_JCEF(SymmetricProtection algorithm,
9259 byte[][] data) throws Throwable {
9260 byte[] result = null;
9261 result = unprotectData_JCEF((Protection) algorithm, data);
9262 return result;
9263 }
9264
9265 /**
9266 * Mediante JCE, desasegura unos datos mediante un algoritmo criptográfico
9267 *
9268 * @param algorithm
9269 * Algoritmo criptográfico
9270 * @param data
9271 * Datos a desasegurar
9272 * @return Datos
9273 */
9274 public static Object unsecureData_JCE(Object algorithm, byte[][] data)
9275 throws Throwable {
9276 Object result = null;
9277 if (algorithm instanceof MessageDigest) {
9278 result = verifyAuthenticator_JCE(algorithm, data);
9279 } else if (algorithm instanceof Mac) {
9280 result = verifyAuthenticator_JCE(algorithm, data);
9281 } else if (algorithm instanceof Signature) {
9282 result = verifyAuthenticator_JCE(algorithm, data);
9283 } else if (algorithm instanceof Cipher) {
9284 result = unprotectData_JCE((Cipher) algorithm, data);
9285 }
9286 return result;
9287 }
9288
9289 /**
9290 * Mediante JCEF, desasegura unos datos mediante un algoritmo criptográfico
9291 * <UL>
9292 * <LI>Para desasegurar un conjunto de datos seguros, éstos se suministran
9293 * de forma iterativa a través de {@link CryptoAlgorithm#unsecure(byte[])}</LI>
9294 * <LI>Finalmente, para terminar se debe llamar a
9295 * {@link Protection#unsecure()} si se tratase de un algoritmo de protección
9296 * o a {@link AuthenticationAlgorithm#isAuthentic(byte[])} si se tratase de
9297 * un algoritmo de autentificación</LI>
9298 * </UL>
9299 *
9300 * @param algorithm
9301 * Algoritmo criptográfico
9302 * @param data
9303 * Datos
9304 * @return Datos asegurados
9305 * @throws Throwable
9306 * Ocurre si no se ha podido realizar
9307 * @see CryptoAlgorithm#unsecure(byte[])
9308 * @see Protection#unsecure()
9309 * @see AuthenticationAlgorithm#isAuthentic(byte[])
9310 * @see CryptoAlgorithm
9311 * @see #verifyAuthenticator_JCEF(AuthenticationAlgorithm, byte[], byte[][])
9312 * @see #unprotectData_JCEF(Protection, byte[][])
9313 */
9314 public static Object unsecureData_JCEF(CryptoAlgorithm algorithm,
9315 byte[][] data) throws Throwable {
9316 Object result = null;
9317 if (algorithm instanceof AuthenticationAlgorithm) {
9318 result = verifyAuthenticator_JCEF(
9319 (AuthenticationAlgorithm) algorithm, data);
9320 } else if (algorithm instanceof Protection) {
9321 result = unprotectData_JCEF((Protection) algorithm, data);
9322 }
9323 return result;
9324 }
9325
9326 /**
9327 * Mediante JCE, desencapsula una clave
9328 *
9329 * @param algorithm
9330 * Algoritmo criptográfico de protección
9331 * @param wrappedKey
9332 * Clave encapsulada
9333 * @param algorithmName
9334 * Nombre del algoritmo para la clave
9335 * @param keyType
9336 * Tipo de clave ({@link Cipher#SECRET_KEY},
9337 * {@link Cipher#PRIVATE_KEY}, {@link Cipher#PUBLIC_KEY}
9338 * @return Clave desencapsulada
9339 * @throws NoSuchAlgorithmException
9340 * Ocurre si no se ha podido realizar la operación
9341 * @throws InvalidKeyException
9342 * Ocurre si no se ha podido realizar la operación
9343 */
9344 public static Key unwrapKey_JCE(Cipher algorithm, byte[] wrappedKey,
9345 String algorithmName, int keyType) throws InvalidKeyException,
9346 NoSuchAlgorithmException {
9347 Key result = null;
9348 result = algorithm.unwrap(wrappedKey, algorithmName, keyType);
9349 return result;
9350 }
9351
9352 /**
9353 * Mediante JCEF, desencapsula una clave
9354 *
9355 * @param algorithm
9356 * Algoritmo criptográfico de protección
9357 * @param wrappedKey
9358 * Clave encapsulada
9359 * @return Clave desencapsulada
9360 * @throws Throwable
9361 * Ocurre si no se ha podido realizar la operación
9362 * @see #unprotectData_JCEF(Protection, byte[][])
9363 */
9364 public static byte[] unwrapKey_JCEF(Protection algorithm, byte[] wrappedKey)
9365 throws Throwable {
9366 byte[] result = null;
9367 byte[][] data = { wrappedKey };
9368 result = unprotectData_JCEF(algorithm, data);
9369 return result;
9370 }
9371
9372 /**
9373 * Mediante JCE, verifica la autenticidad de los datos mediante su
9374 * autentificador
9375 *
9376 * @param algorithm
9377 * Algoritmo de autentificación
9378 * @param data
9379 * Datos a autentificar (el último conjunto es el autentificador)
9380 * @throws Throwable
9381 * Ha ocurrido algún error no deseado
9382 * @return Cierto si los datos son auténticos o falso en caso contrario
9383 * @see #verifyFingerPrint_JCE(MessageDigest, byte[][])
9384 * @see #verifyDigitalSeal_JCE(Mac, byte[][])
9385 * @see #verifyDigitalSignature_JCE(Signature, byte[][])
9386 */
9387 public static Boolean verifyAuthenticator_JCE(Object algorithm,
9388 byte[][] data) throws Throwable {
9389 Boolean result = new Boolean(false);
9390 if (algorithm instanceof MessageDigest) {
9391 result = verifyFingerPrint_JCE((MessageDigest) algorithm, data);
9392 } else if (algorithm instanceof Mac) {
9393 result = verifyDigitalSeal_JCE((Mac) algorithm, data);
9394 } else if (algorithm instanceof Signature) {
9395 result = verifyDigitalSignature_JCE((Signature) algorithm, data);
9396 }
9397 return result;
9398 }
9399
9400 /**
9401 * Mediante JCEF, verifica la autenticidad de unos datos utilizando para
9402 * ello su autentificador y un algoritmo criptográfico de autentificación
9403 * JCEF
9404 * <UL>
9405 * <LI>Para el suministro del conjunto de datos, del cual se va a comprobar
9406 * su autenticidad, se invoca de forma iterativa el método:
9407 * {@link CryptoAlgorithm#unsecure(byte[])}
9408 * <LI>Una vez suministrados todos los datos, se verifica la autenticidad
9409 * de los mismos proporcionando el autentificador original mediante:
9410 * {@link AuthenticationAlgorithm#isAuthentic(byte[])}</LI>
9411 * <LI> Estos son los únicos métodos necesarios para verificar
9412 * autentificadores, ya sean huellas, sellos o firmas digitales. </LI>
9413 * </UL>
9414 *
9415 * @param algorithm
9416 * Algoritmo criptográfico de autentificación JCEF
9417 * @param authenticator
9418 * Autentificador
9419 * @param data
9420 * Datos (el último elemento es el autentificador)
9421 * @return Cierto si los datos son auténticos o falso en caso contrario
9422 * @throws Throwable
9423 * Ocurre si no se ha podido realizar la operación
9424 * @see CryptoAlgorithm#unsecure(byte[])
9425 * @see AuthenticationAlgorithm#isAuthentic(byte[])
9426 * @see AuthenticationAlgorithm
9427 * @see #unsecureData_JCEF(CryptoAlgorithm, byte[][])
9428 * @see #verifyFingerPrint_JCEF(FingerPrint, byte[][])
9429 * @see #verifyDigitalSeal_JCEF(DigitalSeal, byte[][])
9430 * @see #verifyDigitalSignature_JCEF(DigitalSignature, byte[][])
9431 */
9432 public static Boolean verifyAuthenticator_JCEF(
9433 AuthenticationAlgorithm algorithm, byte[][] data) throws Throwable {
9434 Boolean result = new Boolean(false);
9435 byte[] authenticator = data[data.length - 1];
9436 for (int i = 0; data != null && i < data.length - 1; i++) {
9437 algorithm.unsecure(data[i]);
9438 }
9439 result = new Boolean(algorithm.isAuthentic(authenticator));
9440 return result;
9441 }
9442
9443 /**
9444 * Mediante JCE, verifica la autenticidad de unos datos mediante su sello
9445 * digital
9446 * <UL>
9447 * Para esto es necesario realizar los siguientes pasos:
9448 * <LI>Suministrar los datos mediante:
9449 * <UL>
9450 * <LI>{@link Mac#update(byte)}</LI>
9451 * <LI>{@link Mac#update(byte[])}</LI>
9452 * <LI>{@link Mac#update(byte[], int, int)}</LI>
9453 * <LI>{@link Mac#update(java.nio.ByteBuffer)}</LI>
9454 * </UL>
9455 * </LI>
9456 * <LI>Para el suministro de datos y generación del mac actual:
9457 * <UL>
9458 * <LI>{@link Mac#doFinal(byte[])}</LI>
9459 * </UL>
9460 * </LI>
9461 * <LI>Para generar el actual autentificador:
9462 * <UL>
9463 * <LI>{@link Mac#doFinal()}</LI>
9464 * <LI>{@link Mac#doFinal(byte[], int)}</LI>
9465 * </UL>
9466 * </LI>
9467 * <LI>Para comprobar la autenticidad de los datos
9468 * <UL>
9469 * <LI>{@link MessageDigest#isEqual(byte[], byte[])}</LI>
9470 * </UL>
9471 * </LI>
9472 * <LI>Los únicos métodos imprescindibles son:
9473 * <UL>
9474 * <LI>{@link Mac#update(byte[])}</LI>
9475 * <LI>{@link Mac#doFinal()}</LI>
9476 * <LI>{@link MessageDigest#isEqual(byte[], byte[])}</LI>
9477 * </UL>
9478 * </LI>
9479 * </UL>
9480 *
9481 * @param algorithm
9482 * Algoritmo criptográfico de autentificación mediante sellos
9483 * digitales
9484 * @param data
9485 * Datos (el último elemento es el autentificador)
9486 * @return Autenticidad de los datos
9487 * @see #verifyAuthenticator_JCE(Object, byte[][], byte[])
9488 */
9489 public static Boolean verifyDigitalSeal_JCE(Mac algorithm, byte[][] data) {
9490 Boolean result = new Boolean(false);
9491 byte[] authenticator = data[data.length - 1];
9492 for (int i = 0; data != null && i < data.length - 1; i++) {
9493 algorithm.update(data[i]);
9494 }
9495 result = new Boolean(MessageDigest.isEqual(authenticator, algorithm
9496 .doFinal()));
9497 return result;
9498 }
9499
9500 /**
9501 * Mediante JCEF, verifica la autenticidad de unos datos utilizando para
9502 * ello su sello digital y un algoritmo criptográfico de autentificación
9503 * mediante sellos digitales basados en contraseñas
9504 *
9505 * @param algorithm
9506 * Algoritmo criptográfico de autentificación mediante sellos
9507 * digitales basados en contraseñas
9508 * @param authenticator
9509 * Sello digital de los datos basado en contraseña
9510 * @param data
9511 * Datos
9512 * @return Cierto si los datos son auténticos o falso en caso contrario
9513 * @throws Throwable
9514 * Ocurre si no se ha podido realizar la operación
9515 * @see #verifyAuthenticator_JCEF(AuthenticationAlgorithm, byte[], byte[][])
9516 */
9517 public static Boolean verifyDigitalSeal_JCEF(DigitalPBESeal algorithm,
9518 byte[][] data) throws Throwable {
9519 return verifyAuthenticator_JCEF(algorithm, data);
9520 }
9521
9522 /**
9523 * Mediante JCEF, verifica la autenticidad de unos datos utilizando para
9524 * ello su sello digital y un algoritmo criptográfico de autentificación
9525 * mediante sellos digitales
9526 *
9527 * @param algorithm
9528 * Algoritmo criptográfico de autentificación mediante sellos
9529 * digitales
9530 * @param authenticator
9531 * Sello digital de los datos
9532 * @param data
9533 * Datos
9534 * @return Cierto si los datos son auténticos o falso en caso contrario
9535 * @throws Throwable
9536 * Ocurre si no se ha podido realizar la operación
9537 * @see #verifyAuthenticator_JCEF(AuthenticationAlgorithm, byte[], byte[][])
9538 */
9539 public static Boolean verifyDigitalSeal_JCEF(DigitalSeal algorithm,
9540 byte[][] data) throws Throwable {
9541 return verifyAuthenticator_JCEF(algorithm, data);
9542 }
9543
9544 /**
9545 * Mediante JCE, verifica la autenticidad de unos datos mediante su firma
9546 * digital
9547 * <UL>
9548 * Para esto es necesario realizar los siguientes pasos:
9549 * <LI>Suministrar los datos mediante: Se suministran los datos por pedazos
9550 * utilizando cualquiera de los siguientes métodos:
9551 * <UL>
9552 * <LI>{@link Signature#update(byte)}</LI>
9553 * <LI>{@link Signature#update(byte[])}</LI>
9554 * <LI>{@link Signature#update(byte[], int, int)}</LI>
9555 * <LI>{@link Signature#update(java.nio.ByteBuffer)}</LI>
9556 * </UL>
9557 * </LI>
9558 * <LI>Para verificar la autenticidad de los datos suministrados con
9559 * anterioridad, basta con indicar la firma original de dichos datos. Para
9560 * ello se puede utilizar cualquiera de los siguientes métodos:
9561 * <UL>
9562 * <LI>{@link Signature#verify(byte[])}</LI>
9563 * <LI>{@link Signature#verify(byte[], int, int)}</LI>
9564 * </UL>
9565 * </LI>
9566 * <LI>Los únicos métodos imprescindibles son:
9567 * <UL>
9568 * <LI>{@link Signature#update(byte[])}</LI>
9569 * <LI>{@link Signature#verify(byte[])}</LI>
9570 * </UL>
9571 * </LI>
9572 * </UL>
9573 *
9574 * @param algorithm
9575 * Algoritmo criptográfico de autentificación mediante firmas
9576 * digitales
9577 * @param data
9578 * Datos a autentificar (el último elemento es el autentificador)
9579 * @return Autenticidad de los datos
9580 * @see #verifyAuthenticator_JCE(Object, byte[][])
9581 */
9582 public static Boolean verifyDigitalSignature_JCE(Signature algorithm,
9583 byte[][] data) throws SignatureException {
9584 Boolean result = new Boolean(false);
9585 byte[] authenticator = data[data.length - 1];
9586 for (int i = 0; data != null && i < data.length - 1; i++) {
9587 algorithm.update(data[i]);
9588 }
9589 result = new Boolean(algorithm.verify(authenticator));
9590 return result;
9591 }
9592
9593 /**
9594 * Mediante JCEF, verifica la autenticidad de unos datos utilizando para
9595 * ello su firma digital y un algoritmo criptográfico de autentificación
9596 * mediante firmas digitales
9597 *
9598 * @param algorithm
9599 * Algoritmo criptográfico de autentificación mediante firmas
9600 * digitales
9601 * @param data
9602 * Datos (el último elemento es el autentificador)
9603 * @return Cierto si los datos son auténticos o falso en caso contrario
9604 * @throws Throwable
9605 * Ocurre si no se ha podido realizar la operación
9606 * @see #verifyAuthenticator_JCEF(AuthenticationAlgorithm, byte[][])
9607 */
9608 public static Boolean verifyDigitalSignature_JCEF(
9609 DigitalSignature algorithm, byte[][] data) throws Throwable {
9610 return verifyAuthenticator_JCEF(algorithm, data);
9611 }
9612
9613 /**
9614 * Mediante JCE, verifica la autenticidad de unos datos mediante su huella
9615 * digital
9616 * <UL>
9617 * Para estas verificaciones es necesario seguir los siguientes pasos.
9618 * <LI>Para el suministro de datos
9619 * <UL>
9620 * <LI>{@link MessageDigest#update(byte)}</LI>
9621 * <LI>{@link MessageDigest#update(byte[])}</LI>
9622 * <LI>{@link MessageDigest#update(byte[], int, int)}</LI>
9623 * <LI>{@link MessageDigest#update(java.nio.ByteBuffer)}</LI>
9624 * </UL>
9625 * </LI>
9626 * <LI>Para el suministro de datos y generación del actual autentificador:
9627 * <UL>
9628 * <LI>{@link MessageDigest#digest(byte[])}</LI>
9629 * </UL>
9630 * </LI>
9631 * <LI>Para generar el actual autentificador:
9632 * <UL>
9633 * <LI>{@link MessageDigest#digest()}</LI>
9634 * <LI>{@link MessageDigest#digest(byte[], int, int)}</LI>
9635 * </UL>
9636 * </LI>
9637 * <LI>Para comprobar la autenticidad de los datos
9638 * <UL>
9639 * <LI>{@link MessageDigest#isEqual(byte[], byte[])}</LI>
9640 * </UL>
9641 * </LI>
9642 * <LI>Los únicos métodos imprescindibles son:
9643 * <UL>
9644 * <LI>{@link MessageDigest#update(byte[])}</LI>
9645 * <LI>{@link MessageDigest#digest()}</LI>
9646 * <LI>{@link MessageDigest#isEqual(byte[], byte[])}</LI>
9647 * </UL>
9648 * </LI>
9649 * </UL>
9650 *
9651 * @param algorithm
9652 * Algoritmo criptográfico de autentificación mediante huellas
9653 * digitales
9654 * @param data
9655 * Datos a autentificar (el último elemento es el autentificador)
9656 * @return Autenticidad de los datos
9657 * @see #verifyAuthenticator_JCE(Object, byte[][])
9658 */
9659 public static Boolean verifyFingerPrint_JCE(MessageDigest algorithm,
9660 byte[][] data) {
9661 Boolean result = new Boolean(false);
9662 byte[] authenticator = data[data.length - 1];
9663 for (int i = 0; data != null && i < data.length - 1; i++) {
9664 algorithm.update(data[i]);
9665 }
9666 result = new Boolean(MessageDigest.isEqual(authenticator, algorithm
9667 .digest()));
9668 return result;
9669 }
9670
9671 /**
9672 * Mediante JCEF, verifica la autenticidad de unos datos utilizando para
9673 * ello su huella digital y un algoritmo criptográfico de autentificación
9674 * mediante huellas digitales JCEF
9675 *
9676 * @param algorithm
9677 * Algoritmo criptográfico de autentificación mediante huellas
9678 * digitales
9679 * @param data
9680 * Datos (el último elemento es el autentificador)
9681 * @return Cierto si los datos son auténticos o falso en caso contrario
9682 * @throws Throwable
9683 * Ocurre si no se ha podido realizar la operación
9684 * @see #verifyAuthenticator_JCEF(AuthenticationAlgorithm, byte[][])
9685 */
9686 public static Boolean verifyFingerPrint_JCEF(FingerPrint algorithm,
9687 byte[][] data) throws Throwable {
9688 return verifyAuthenticator_JCEF(algorithm, data);
9689 }
9690
9691 /**
9692 * Mediante JCE, encapsula una clave. Encapsular una clave es protegerla
9693 * como si fuera un objeto
9694 *
9695 * @param algorithm
9696 * Algoritmo criptográfico de protección
9697 * @param key
9698 * Clave a encapsular
9699 * @return Clave encapsulada
9700 * @throws IllegalBlockSizeException
9701 * Ocurre si no se ha podido realizar la operación
9702 * @throws InvalidKeyException
9703 * Ocurre si no se ha podido realizar la operación
9704 */
9705 public static byte[] wrapKey_JCE(Cipher algorithm, Key key)
9706 throws InvalidKeyException, IllegalBlockSizeException {
9707 byte[] result = null;
9708 result = algorithm.wrap(key);
9709 return result;
9710 }
9711
9712 /**
9713 * Mediante JCEF, encapsula una clave
9714 *
9715 * @param algorithm
9716 * Algoritmo criptográfico de protección
9717 * @param key
9718 * Clave a encapsular
9719 * @return Clave encapsulada
9720 * @throws Throwable
9721 * Ocurre si no se ha podido realizar la operación
9722 * @see #protectData_JCEF(Protection, byte[][])
9723 */
9724 public static byte[] wrapKey_JCEF(Protection algorithm, Key key)
9725 throws Throwable {
9726 byte[] result = null;
9727 byte[][] data = { key.getEncoded() };
9728 result = protectData_JCEF(algorithm, data);
9729 return result;
9730 }
9731
9732 }
9733
9734 /**
9735 * Muestra cómo se utilizan objetos seguros
9736 */
9737 public static class UsingSecureObject {
9738
9739 /**
9740 * Mediante JCEF, construye un objeto seguro mediante un algoritmo
9741 * criptográfico
9742 *
9743 * @param object
9744 * Objeto a asegurar
9745 * @param algorithm
9746 * Algoritmo criptográfico
9747 * @return Objeto seguro
9748 * @throws Throwable
9749 * Ocurre si no se ha podido realizar la operación
9750 */
9751 public static SecureObject createSecureObject_JCEF(Object object,
9752 CryptoAlgorithm algorithm) throws Throwable {
9753 SecureObject result = null;
9754 result = new SecureObject(object, algorithm);
9755 return result;
9756 }
9757
9758 /**
9759 * Mediante JCEF, obtiene el objeto asegurado por el objeto seguro mediante
9760 * un algoritmo criptográfico
9761 *
9762 * @param secureObject
9763 * Objeto seguro
9764 * @param algorithm
9765 * Algoritmo criptográfico
9766 * @return Objeto asegurado
9767 * @throws Throwable
9768 * Ocurre si no se ha podido realizar la operación
9769 */
9770 public static Object getObject_JCEF(SecureObject secureObject,
9771 CryptoAlgorithm algorithm) throws Throwable {
9772 Object result = null;
9773 result = secureObject.getObject(algorithm);
9774 return result;
9775 }
9776
9777 /**
9778 * Mediante JCEF, construye un objeto seguro protegido mediante un algoritmo
9779 * criptográfico de protección
9780 *
9781 * @param object
9782 * Objeto a asegurar
9783 * @param algorithm
9784 * Algoritmo criptográfico de protección
9785 * @return Objeto seguro protegido
9786 * @throws Throwable
9787 * Ocurre si no se ha podido realizar la operación
9788 */
9789 public static SecureObject createProtectedObject_JCEF(Object object,
9790 Protection algorithm) throws Throwable {
9791 SecureObject result = null;
9792 result = new SecureObject(object, algorithm);
9793 return result;
9794 }
9795
9796 /**
9797 * Mediante JCEF, obtiene el objeto asegurado por el objeto seguro mediante
9798 * un algoritmo criptográfico de protección
9799 *
9800 * @param secureObject
9801 * Objeto seguro
9802 * @param algorithm
9803 * Algoritmo criptográfico de protección
9804 * @return Objeto asegurado
9805 * @throws Throwable
9806 * Ocurre si no se ha podido realizar la operación
9807 */
9808 public static Object getObject_JCEF(SecureObject secureObject,
9809 Protection algorithm) throws Throwable {
9810 Object result = null;
9811 result = secureObject.getObject(algorithm);
9812 return result;
9813 }
9814
9815 /**
9816 * Mediante JCEF, construye un objeto seguro protegido mediante un algoritmo
9817 * criptográfico de protección asimétrica
9818 *
9819 * @param object
9820 * Objeto a asegurar
9821 * @param algorithm
9822 * Algoritmo criptográfico de protección asimétrica
9823 * @return Objeto seguro protegido
9824 * @throws Throwable
9825 * Ocurre si no se ha podido realizar la operación
9826 */
9827 public static SecureObject createProtectedObject_JCEF(Object object,
9828 AsymmetricProtection algorithm) throws Throwable {
9829 SecureObject result = null;
9830 result = new SecureObject(object, algorithm);
9831 return result;
9832 }
9833
9834 /**
9835 * Mediante JCEF, obtiene el objeto asegurado por el objeto seguro mediante
9836 * un algoritmo criptográfico de protección asimétrica
9837 *
9838 * @param secureObject
9839 * Objeto seguro
9840 * @param algorithm
9841 * Algoritmo criptográfico de protección asimétrica
9842 * @return Objeto asegurado
9843 * @throws Throwable
9844 * Ocurre si no se ha podido realizar la operación
9845 */
9846 public static Object getObject_JCEF(SecureObject secureObject,
9847 AsymmetricProtection algorithm) throws Throwable {
9848 Object result = null;
9849 result = secureObject.getObject(algorithm);
9850 return result;
9851 }
9852
9853 /**
9854 * Mediante JCEF, construye un objeto seguro protegido mediante un algoritmo
9855 * criptográfico de protección simétrica
9856 *
9857 * @param object
9858 * Objeto a asegurar
9859 * @param algorithm
9860 * Algoritmo criptográfico de protección simétrica
9861 * @return Objeto seguro protegido
9862 * @throws Throwable
9863 * Ocurre si no se ha podido realizar la operación
9864 */
9865 public static SecureObject createProtectedObject_JCEF(Object object,
9866 SymmetricProtection algorithm) throws Throwable {
9867 SecureObject result = null;
9868 result = new SecureObject(object, algorithm);
9869 return result;
9870 }
9871
9872 /**
9873 * Mediante JCEF, obtiene el objeto asegurado por el objeto seguro mediante
9874 * un algoritmo criptográfico de protección simétrica
9875 *
9876 * @param secureObject
9877 * Objeto seguro
9878 * @param algorithm
9879 * Algoritmo criptográfico de protección simétrica
9880 * @return Objeto asegurado
9881 * @throws Throwable
9882 * Ocurre si no se ha podido realizar la operación
9883 */
9884 public static Object getObject_JCEF(SecureObject secureObject,
9885 SymmetricProtection algorithm) throws Throwable {
9886 Object result = null;
9887 result = secureObject.getObject(algorithm);
9888 return result;
9889 }
9890
9891 /**
9892 * Mediante JCEF, construye un objeto seguro protegido mediante un algoritmo
9893 * criptográfico de protección simétrica de bloques
9894 *
9895 * @param object
9896 * Objeto a asegurar
9897 * @param algorithm
9898 * Algoritmo criptográfico de protección simétrica de bloques
9899 * @return Objeto seguro protegido
9900 * @throws Throwable
9901 * Ocurre si no se ha podido realizar la operación
9902 */
9903 public static SecureObject createProtectedObject_JCEF(Object object,
9904 BlockSymmetricProtection algorithm) throws Throwable {
9905 SecureObject result = null;
9906 result = new SecureObject(object, algorithm);
9907 return result;
9908 }
9909
9910 /**
9911 * Mediante JCEF, obtiene el objeto asegurado por el objeto seguro mediante
9912 * un algoritmo criptográfico de protección simétrica de bloques
9913 *
9914 * @param secureObject
9915 * Objeto seguro
9916 * @param algorithm
9917 * Algoritmo criptográfico de protección simétrica de bloques
9918 * @return Objeto asegurado
9919 * @throws Throwable
9920 * Ocurre si no se ha podido realizar la operación
9921 */
9922 public static Object getObject_JCEF(SecureObject secureObject,
9923 BlockSymmetricProtection algorithm) throws Throwable {
9924 Object result = null;
9925 result = secureObject.getObject(algorithm);
9926 return result;
9927 }
9928
9929 /**
9930 * Mediante JCEF, construye un objeto seguro protegido mediante un algoritmo
9931 * criptográfico de protección simétrica de flujo
9932 *
9933 * @param object
9934 * Objeto a asegurar
9935 * @param algorithm
9936 * Algoritmo criptográfico de protección simétrica de flujo
9937 * @return Objeto seguro protegido
9938 * @throws Throwable
9939 * Ocurre si no se ha podido realizar la operación
9940 */
9941 public static SecureObject createProtectedObject_JCEF(Object object,
9942 StreamSymmetricProtection algorithm) throws Throwable {
9943 SecureObject result = null;
9944 result = new SecureObject(object, algorithm);
9945 return result;
9946 }
9947
9948 /**
9949 * Mediante JCEF, obtiene el objeto asegurado por el objeto seguro mediante
9950 * un algoritmo criptográfico de protección simétrica de flujo
9951 *
9952 * @param secureObject
9953 * Objeto seguro
9954 * @param algorithm
9955 * Algoritmo criptográfico de protección simétrica de flujo
9956 * @return Objeto asegurado
9957 * @throws Throwable
9958 * Ocurre si no se ha podido realizar la operación
9959 */
9960 public static Object getObject_JCEF(SecureObject secureObject,
9961 StreamSymmetricProtection algorithm) throws Throwable {
9962 Object result = null;
9963 result = secureObject.getObject(algorithm);
9964 return result;
9965 }
9966
9967 /**
9968 * Mediante JCEF, construye un objeto seguro protegido mediante un algoritmo
9969 * criptográfico de protección basada en contraseña
9970 *
9971 * @param object
9972 * Objeto a asegurar
9973 * @param algorithm
9974 * Algoritmo criptográfico de protección basada en contraseña
9975 * @return Objeto seguro protegido
9976 * @throws Throwable
9977 * Ocurre si no se ha podido realizar la operación
9978 */
9979 public static SecureObject createProtectedObject_JCEF(Object object,
9980 PBEProtection algorithm) throws Throwable {
9981 SecureObject result = null;
9982 result = new SecureObject(object, algorithm);
9983 return result;
9984 }
9985
9986 /**
9987 * Mediante JCEF, obtiene el objeto asegurado por el objeto seguro mediante
9988 * un algoritmo criptográfico de protección basada en contraseña
9989 *
9990 * @param secureObject
9991 * Objeto seguro
9992 * @param algorithm
9993 * Algoritmo criptográfico de protección basada en contraseña
9994 * @return Objeto asegurado
9995 * @throws Throwable
9996 * Ocurre si no se ha podido realizar la operación
9997 */
9998 public static Object getObject_JCEF(SecureObject secureObject,
9999 PBEProtection algorithm) throws Throwable {
10000 Object result = null;
10001 result = secureObject.getObject(algorithm);
10002 return result;
10003 }
10004
10005 /**
10006 * Mediante JCEF, construye un objeto seguro autentificable mediante un
10007 * algoritmo criptográfico de autentificación
10008 *
10009 * @param object
10010 * Objeto a asegurar
10011 * @param algorithm
10012 * Algoritmo criptográfico de autentificación
10013 * @return Objeto seguro autentificable
10014 * @throws Throwable
10015 * Ocurre si no se ha podido realizar la operación
10016 */
10017 public static SecureObject createAuthenticableObject_JCEF(Object object,
10018 AuthenticationAlgorithm algorithm) throws Throwable {
10019 SecureObject result = null;
10020 result = new SecureObject(object, algorithm);
10021 return result;
10022 }
10023
10024 /**
10025 * Mediante JCEF, obtiene el objeto asegurado por el objeto seguro mediante
10026 * un algoritmo criptográfico de autentificación
10027 *
10028 * @param secureObject
10029 * Objeto seguro
10030 * @param algorithm
10031 * Algoritmo criptográfico de autentificación
10032 * @return Objeto asegurado
10033 * @throws Throwable
10034 * Ocurre si no se ha podido realizar la operación
10035 */
10036 public static Object getObject_JCEF(SecureObject secureObject,
10037 AuthenticationAlgorithm algorithm) throws Throwable {
10038 Object result = null;
10039 result = secureObject.getObject(algorithm);
10040 return result;
10041 }
10042
10043 /**
10044 * Mediante JCEF, construye un objeto seguro autentificable mediante un
10045 * algoritmo criptográfico de autentificación mediante huellas digitales
10046 *
10047 * @param object
10048 * Objeto a asegurar
10049 * @param algorithm
10050 * Algoritmo criptográfico de autentificación mediante huellas
10051 * digitales
10052 * @return Objeto seguro autentificable
10053 * @throws Throwable
10054 * Ocurre si no se ha podido realizar la operación
10055 */
10056 public static SecureObject createAuthenticableObjectWithFingerPrint_JCEF(
10057 Object object, FingerPrint algorithm) throws Throwable {
10058 SecureObject result = null;
10059 result = new SecureObject(object, algorithm);
10060 return result;
10061 }
10062
10063 /**
10064 * Mediante JCEF, obtiene el objeto asegurado por el objeto seguro mediante
10065 * un algoritmo criptográfico de autentificación mediante huellas digitales
10066 *
10067 * @param secureObject
10068 * Objeto seguro
10069 * @param algorithm
10070 * Algoritmo criptográfico de autentificación mediante huellas
10071 * digitales
10072 * @return Objeto asegurado
10073 * @throws Throwable
10074 * Ocurre si no se ha podido realizar la operación
10075 */
10076 public static Object getObject_JCEF(SecureObject secureObject,
10077 FingerPrint algorithm) throws Throwable {
10078 Object result = null;
10079 result = secureObject.getObject(algorithm);
10080 return result;
10081 }
10082
10083 /**
10084 * Mediante JCEF, construye un objeto seguro autentificable mediante un
10085 * algoritmo criptográfico de autentificación mediante sellos digitales
10086 *
10087 * @param object
10088 * Objeto a asegurar
10089 * @param algorithm
10090 * Algoritmo criptográfico de autentificación mediante sellos
10091 * digitales
10092 * @return Objeto seguro autentificable
10093 * @throws Throwable
10094 * Ocurre si no se ha podido realizar la operación
10095 */
10096 public static SecureObject createAuthenticableObjectWithDigitalSeal_JCEF(
10097 Object object, DigitalSeal algorithm) throws Throwable {
10098 SecureObject result = null;
10099 result = new SecureObject(object, algorithm);
10100 return result;
10101 }
10102
10103 /**
10104 * Mediante JCEF, obtiene el objeto asegurado por el objeto seguro mediante
10105 * un algoritmo criptográfico de autentificación mediante sellos digitales
10106 *
10107 * @param secureObject
10108 * Objeto seguro
10109 * @param algorithm
10110 * Algoritmo criptográfico de autentificación mediante sellos
10111 * digitales
10112 * @return Objeto asegurado
10113 * @throws Throwable
10114 * Ocurre si no se ha podido realizar la operación
10115 */
10116 public static Object getObject_JCEF(SecureObject secureObject,
10117 DigitalSeal algorithm) throws Throwable {
10118 Object result = null;
10119 result = secureObject.getObject(algorithm);
10120 return result;
10121 }
10122
10123 /**
10124 * Mediante JCEF, construye un objeto seguro autentificable mediante un
10125 * algoritmo criptográfico de autentificación mediante sellos digitales
10126 * basados en contraseñas
10127 *
10128 * @param object
10129 * Objeto a asegurar
10130 * @param algorithm
10131 * Algoritmo criptográfico de autentificación mediante sellos
10132 * digitales basados en contraseñas
10133 * @return Objeto seguro autentificable
10134 * @throws Throwable
10135 * Ocurre si no se ha podido realizar la operación
10136 */
10137 public static SecureObject createAuthenticableObjectWithDigitalSeal_JCEF(
10138 Object object, DigitalPBESeal algorithm) throws Throwable {
10139 SecureObject result = null;
10140 result = new SecureObject(object, algorithm);
10141 return result;
10142 }
10143
10144 /**
10145 * Mediante JCEF, obtiene el objeto asegurado por el objeto seguro mediante
10146 * un algoritmo criptográfico de autentificación mediante sellos digitales
10147 * basados en contraseña
10148 *
10149 * @param secureObject
10150 * Objeto seguro
10151 * @param algorithm
10152 * Algoritmo criptográfico de autentificación mediante sellos
10153 * digitales basados en contraseña
10154 * @return Objeto asegurado
10155 * @throws Throwable
10156 * Ocurre si no se ha podido realizar la operación
10157 */
10158 public static Object getObject_JCEF(SecureObject secureObject,
10159 DigitalPBESeal algorithm) throws Throwable {
10160 Object result = null;
10161 result = secureObject.getObject(algorithm);
10162 return result;
10163 }
10164
10165 /**
10166 * Mediante JCEF, construye un objeto seguro autentificable mediante un
10167 * algoritmo criptográfico de autentificación mediante firmas digitales
10168 *
10169 * @param object
10170 * Objeto a asegurar
10171 * @param algorithm
10172 * Algoritmo criptográfico de autentificación mediante firmas
10173 * digitales
10174 * @return Objeto seguro autentificable
10175 * @throws Throwable
10176 * Ocurre si no se ha podido realizar la operación
10177 */
10178 public static SecureObject createAuthenticableObjectWithDigitalSignature_JCEF(
10179 Object object, DigitalSignature algorithm) throws Throwable {
10180 SecureObject result = null;
10181 result = new SecureObject(object, algorithm);
10182 return result;
10183 }
10184
10185 /**
10186 * Mediante JCEF, obtiene el objeto asegurado por el objeto seguro mediante
10187 * un algoritmo criptográfico de autentificación mediante firmas digitales
10188 *
10189 * @param secureObject
10190 * Objeto seguro
10191 * @param algorithm
10192 * Algoritmo criptográfico de autentificación mediante firmas
10193 * digitales
10194 * @return Objeto asegurado
10195 * @throws Throwable
10196 * Ocurre si no se ha podido realizar la operación
10197 */
10198 public static Object getObject_JCEF(SecureObject secureObject,
10199 DigitalSignature algorithm) throws Throwable {
10200 Object result = null;
10201 result = secureObject.getObject(algorithm);
10202 return result;
10203 }
10204
10205 /**
10206 * Mediante JCE, construye un objeto protegido mediante un algoritmo
10207 * criptográfico de protección
10208 *
10209 * @param object
10210 * Objeto a asegurar
10211 * @param algorithm
10212 * Algoritmo criptográfico de protección
10213 * @return Objeto protegido
10214 * @throws Throwable
10215 * Ocurre si no se ha podido realizar la operación
10216 */
10217 public static SealedObject createProtectedObject_JCE(Object object,
10218 Cipher algorithm) throws IllegalBlockSizeException, IOException {
10219 SealedObject result = null;
10220 if (object instanceof Serializable) {
10221 result = new SealedObject((Serializable) object, algorithm);
10222 }
10223 return result;
10224 }
10225
10226 /**
10227 * Mediante JCE, obtiene el objeto asegurado por el objeto seguro mediante
10228 * un algoritmo criptográfico de protección
10229 *
10230 * @param secureObject
10231 * Objeto seguro
10232 * @param algorithm
10233 * Algoritmo criptográfico de protección
10234 * @return Objeto asegurado
10235 * @throws IllegalBlockSizeException
10236 * Ocurre si no se ha podido realizar la operación
10237 * @throws BadPaddingException
10238 * Ocurre si no se ha podido realizar la operación
10239 * @throws IOException
10240 * Ocurre si no se ha podido realizar la operación
10241 * @throws ClassNotFoundException
10242 * Ocurre si no se ha podido realizar la operación
10243 */
10244 public static Object getObject_JCE(SealedObject secureObject,
10245 Cipher algorithm) throws IllegalBlockSizeException,
10246 BadPaddingException, IOException, ClassNotFoundException {
10247 Object result = null;
10248 result = secureObject.getObject(algorithm);
10249 return result;
10250 }
10251
10252 /**
10253 * Mediante JCE, construye un objeto seguro autentificable mediante un
10254 * algoritmo criptográfico de autentificación mediante firmas digitales
10255 *
10256 * @param object
10257 * Objeto a asegurar
10258 * @param signingKey
10259 * Clave de firmado
10260 * @param algorithm
10261 * Algoritmo criptográfico de autentificación mediante firmas
10262 * digitales
10263 * @return Objeto seguro autentificable
10264 * @throws Throwable
10265 * Ocurre si no se ha podido realizar la operación
10266 */
10267 public static SignedObject createSecureObjectWithDigitalSignature_JCE(
10268 Object object, PrivateKey signingKey, Signature algorithm)
10269 throws InvalidKeyException, SignatureException, IOException {
10270 SignedObject result = null;
10271 if (object instanceof Serializable) {
10272 result = new SignedObject((Serializable) object, signingKey,
10273 algorithm);
10274 }
10275 return result;
10276 }
10277
10278 /**
10279 * Mediante JCE, obtiene el objeto asegurado por el objeto seguro mediante
10280 * un algoritmo criptográfico de autentificación mediante firmas digitales
10281 *
10282 * @param secureObject
10283 * Objeto seguro
10284 * @param verifyKey
10285 * Clave de verificación
10286 * @param algorithm
10287 * Algoritmo criptográfico de autentificación mediante firmas
10288 * digitales
10289 * @return Objeto asegurado
10290 * @throws ClassNotFoundException
10291 * Ocurre si no se ha podido realizar la operación
10292 * @throws IOException
10293 * Ocurre si no se ha podido realizar la operación
10294 * @throws SignatureException
10295 * Ocurre si no se ha podido realizar la operació
10296 * @throws InvalidKeyException
10297 * Ocurre si no se ha podido realizar la operación
10298 */
10299 public static Object getObject_JCE(SignedObject secureObject,
10300 PublicKey verifyKey, Signature algorithm)
10301 throws InvalidKeyException, SignatureException, IOException,
10302 ClassNotFoundException {
10303 Object result = null;
10304 if (secureObject.verify(verifyKey, algorithm)) {
10305 result = secureObject.getObject();
10306 }
10307 return result;
10308 }
10309
10310 }
10311
10312 }