de.tsl2.nano.core.secure.Crypt.class Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tsl2.nano.h5 Show documentation
Show all versions of tsl2.nano.h5 Show documentation
TSL2 Framework Html5 Extensions (WebServer, Html5Presentation, RuleCover, BeanConfigurator, LogicTable-Sheet, Expression-Descriptors for Actions, Rules, URLs, Queries)
???? =? AES
de/tsl2/nano/core/secure/Crypt generateRandomKey '(Ljava/lang/String;)Ljava/security/Key;
AES/CBC/PKCS5Padding UTF-8
;(Ljava/security/Key;Ljava/lang/String;Ljava/lang/String;Z)V DES/ECB/PKCS5Padding
generateSecretKey )([BLjava/lang/String;)Ljava/security/Key;
getAlgorithmFromPath &(Ljava/lang/String;)Ljava/lang/String;
generateKey ! " # java/security/Key getAlgorithm ()Ljava/lang/String;
% & ' ( java/lang/Object ()V * + , key Ljava/security/Key; . / 0 algorithm Ljava/lang/String; 2 3 0 encoding 5 6 7 useBASE64 Z
9 : ; createParamSpec R(Ljava/lang/String;Ljava/security/Key;)Ljava/security/spec/AlgorithmParameterSpec; = > ? paramSpec +Ljava/security/spec/AlgorithmParameterSpec; A B C LOG Lorg/apache/commons/logging/Log; E F G H I org/apache/commons/logging/Log isDebugEnabled ()Z
K L # providers E N O P debug (Ljava/lang/Object;)V
R S T provide (Ljava/lang/String;)V
V W X isPBE (Ljava/lang/String;)Z
Z [ \ toCharArray ([B)[C
^ _ ` generatePBEKey )([CLjava/lang/String;)Ljava/security/Key; b java/lang/String
a d e ([BLjava/lang/String;)V
a g [ h ()[C j $java/io/UnsupportedEncodingException
l m n o p "de/tsl2/nano/core/ManagedException forward ,(Ljava/lang/Throwable;)Ljava/lang/Throwable; r s t makeConcatWithConstants J(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; v /
x y z { t !de/tsl2/nano/core/util/StringUtil substring } java/lang/StringBuilder available security providers:
| ? T
? ? ? ? ? java/security/Security getProviders ()[Ljava/security/Provider;
? ? ? ? # java/security/Provider getInfo ? s
| ? ? ? append -(Ljava/lang/String;)Ljava/lang/StringBuilder;
| ? ? # toString
? ? ? ? ? javax/crypto/SecretKeyFactory getInstance 3(Ljava/lang/String;)Ljavax/crypto/SecretKeyFactory; ? java/lang/Exception
? ? T downloadProvider
? ? ? ? ? java/lang/Thread
currentThread ()Ljava/lang/Thread;
? ? ? ? getContextClassLoader ()Ljava/lang/ClassLoader; ? 0de/tsl2/nano/core/classloader/NetworkClassLoader ? .de/tsl2/nano/core/execution/CompatibilityLayer
? & ? $de.tsl2.nano.jarresolver.JarResolver ? org.bouncycastle
? ? ? ? runOptionalMain ((Ljava/lang/String;[Ljava/lang/String;)V
? ? ? createPBEParamSpec -()Ljava/security/spec/AlgorithmParameterSpec;
a ? ? ? contains (Ljava/lang/CharSequence;)Z ? ECB ? !javax/crypto/spec/IvParameterSpec ? DES
a ? ? X
startsWith ? ? ? salt8 [B ? ? ? salt16
? ? ? ([B)V ? RSA ? )java/security/spec/RSAKeyGenParameterSpec ? ? ? ? F4 Ljava/math/BigInteger;
? ? ? (ILjava/math/BigInteger;)V ? "javax/crypto/spec/PBEParameterSpec
? ? ? ([BI)V
? ? T preInit ? javax/crypto/spec/SecretKeySpec
? d ? javax/crypto/spec/PBEKeySpec
? ? ? ([C)V
? ? ? ? generateSecret 6(Ljava/security/spec/KeySpec;)Ljavax/crypto/SecretKey;
? ? ? ? ? javax/crypto/KeyGenerator /(Ljava/lang/String;)Ljavax/crypto/KeyGenerator; ? java/security/SecureRandom
? &
? ? ? ? init (Ljava/security/SecureRandom;)V
? ? ()Ljavax/crypto/SecretKey;
? java/security/KeyPairGenerator 4(Ljava/lang/String;)Ljava/security/KeyPairGenerator;
: ?(Ljava/lang/String;)Ljava/security/spec/AlgorithmParameterSpec;
initialize .(Ljava/security/spec/AlgorithmParameterSpec;)V
generateKeyPair ()Ljava/security/KeyPair; SHA1PRNG
generatePassword (Ljava/lang/String;[B)V
x toHexString ([B)Ljava/lang/String;
? ? 0(Ljava/lang/String;)Ljava/security/SecureRandom;
? ? nextBytes" &java/security/NoSuchAlgorithmException$ PBE& SHA-512
()* hashHex 8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;, UTF8 . s*
x012
toInputStream )(Ljava/lang/String;)Ljava/io/InputStream;
4)5 ;(Ljava/io/InputStream;Ljava/lang/String;)Ljava/lang/String;
789 hash +(Ljava/io/InputStream;Ljava/lang/String;)[B
;< hex
>?@ ?A java/security/MessageDigest 1(Ljava/lang/String;)Ljava/security/MessageDigest;
>CD ? updateF java/security/DigestInputStream
EH I 5(Ljava/io/InputStream;Ljava/security/MessageDigest;)V
EKLM read ()I
EOPQ getMessageDigest ()Ljava/security/MessageDigest;
>STU digest ()[BW .*
YZ[ encrypt >(Ljava/io/InputStream;Ljava/lang/String;)Ljava/io/InputStream;] de/tsl2/nano/core/secure/Crypt$1_ javax/crypto/Cipher
abc cipher h(Ljava/lang/String;ILjava/security/Key;Ljava/security/spec/AlgorithmParameterSpec;)Ljavax/crypto/Cipher;
\e f M(Lde/tsl2/nano/core/secure/Crypt;Ljava/io/InputStream;Ljavax/crypto/Cipher;)V
hi[ decryptk de/tsl2/nano/core/secure/Crypt$2
je
anop getBytes (Ljava/lang/String;)[B
r +s ()Ljava/security/Key;
auvM length
xZy {([BLjava/security/Key;Ljava/security/spec/AlgorithmParameterSpec;Ljava/lang/String;Ljava/lang/String;ZII)Ljava/lang/String;
a{oU
^}~ doFinal ([BII)[B
?? encodeBase64
????? java/util/Base64
getEncoder ()Ljava/util/Base64$Encoder;
???? java/util/Base64$Encoder encodeToString
^? ?? )(Ljava/lang/String;)Ljavax/crypto/Cipher;
^? ?? B(ILjava/security/Key;Ljava/security/spec/AlgorithmParameterSpec;)V? java/lang/Integer???
?i? ?(Ljava/lang/String;Ljava/security/Key;Ljava/security/spec/AlgorithmParameterSpec;Ljava/lang/String;Ljava/lang/String;ZII)Ljava/lang/String;
??p decodeBase64
????
getDecoder ()Ljava/util/Base64$Decoder;
????p java/util/Base64$Decoder decode ????? java/lang/System out Ljava/io/PrintStream;
???? T java/io/PrintStream println? -file:
?? getFileName? java/io/InputStream
????? java/lang/Class isAssignableFrom (Ljava/lang/Class;)Z
????2 de/tsl2/nano/core/util/FileUtil getFile
???? getFileBytes -(Ljava/lang/String;Ljava/lang/ClassLoader;)[B
a ?? "java/lang/IllegalArgumentException ? s? %(Ljava/lang/Class;)Ljava/lang/String;
? ?? 'java/lang/UnsupportedOperationException
? &? SHA-256
??* sign
?Z
??? verify 9(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
?i
a??? equals (Ljava/lang/Object;)Z? java/lang/IllegalStateException? 3the given signature does not fit to the datas hash!
? ?
%??? getClass ()Ljava/lang/Class;
????? java/lang/Boolean valueOf (Z)Ljava/lang/Boolean;
??? ?? de/tsl2/nano/core/util/Util 8(Ljava/lang/Class;[Ljava/lang/Object;)Ljava/lang/String;8
??? getData 7(Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;
x???
cryptoHash ((Ljava/lang/String;Ljava/lang/String;)[B .
T log
d -base64
de/tsl2/nano/core/util/ByteUtil toByteArray (Ljava/io/InputStream;)[B ?
?
writeBytes ([BLjava/lang/String;Z)V
getInputStream ([B)Ljava/io/InputStream; ?
? write *(Ljava/io/InputStream;Ljava/lang/String;)J ? ? ]usage: Crypt * example 1: Crypt mYpASsWord AES meintext! ' example 2: Crypt hash 32 MD5 meintext# 8 example 3: Crypt mYpASsWord AES -file:meintextfile.txt% O example 4: Crypt mYpASsWord AES -file:meintextfile.txt -base64 -include:[^;]+' algorithms are:) ? AES,AESWrap,ARCFOUR,Blowfish,CCM,DES,DESede,DESedeWrap,ECIES,GCM,PBEWithAnd,RC2,RC4,RC5,RSA
Hash: MD2, MD5, SHA, SHA-1, SHA-256, SHA-384, SHA-512 ?, x for further informations see: http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#Cipher
./012 de/tsl2/nano/core/log/LogFactory getLog 3(Ljava/lang/Class;)Lorg/apache/commons/logging/Log;4 de/tsl2/nano/core/secure/ISecure ENCODE_UTF8
ConstantValue ALGO_DES ALGO_AES ALGO_AES_NOPADDING; AES/CBC/NoPadding ALGO_PBEWithSHAAndAES> PBEWithSHAAndAES ALGO_PBEWithMD5AndDESA PBEWithMD5AndDES ALGO_PBEWithHmacSHA1AndDESedeD PBEWithHmacSHA1AndDESede HASH_SHA_256 Code LineNumberTable LocalVariableTable this Lde/tsl2/nano/core/secure/Crypt; pwd
StackMapTable ? (Ljava/security/Key;)V e &Ljava/io/UnsupportedEncodingException; getTransformationPath mode padding path i I ps Ljava/lang/StringBuilder; [Ljava/security/Provider;Y Ljava/lang/Exception;
algorithm2 cl Ljava/lang/ClassLoader;` java/lang/ClassLoaderb )java/security/spec/AlgorithmParameterSpec
pbeKeySpec Ljavax/crypto/spec/PBEKeySpec; keyFac Ljavax/crypto/SecretKeyFactory; [C generator Ljavax/crypto/KeyGenerator; +(Ljava/lang/String;)Ljava/security/KeyPair; kpg Ljava/security/KeyPairGenerator; (B)Ljava/lang/String; B passwordBuffer (Ljava/security/NoSuchAlgorithmException; txt stream Ljava/io/InputStream; Ljava/security/MessageDigest; digestStream !Ljava/security/DigestInputStream; ,(Ljava/io/InputStream;)Ljava/io/InputStream; contentExpression data ;([BLjava/security/Key;Ljava/lang/String;)Ljava/lang/String; raw offset ex spec Ljavax/crypto/Cipher;
Exceptions encrypted v(Ljava/lang/String;Ljava/security/Key;Ljava/security/spec/AlgorithmParameterSpec;Ljava/lang/String;)Ljava/lang/String; bytes base64Length (I)I n base64ToByteLength arg type Ljava/lang/Class; LocalVariableTypeTable Ljava/lang/Class; Signature C(Ljava/lang/String;Ljava/lang/Class;)TT;
canDecrypt validate certificate
hashAlgorithm '(Ljava/lang/String;Ljava/lang/String;)V signature main ([Ljava/lang/String;)V base64 ii include c args [Ljava/lang/String;?
SourceFile
Crypt.java NestMembers BootstrapMethods?
??? s? $java/lang/invoke/StringConcatFactory ?(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;? //?
? ? not allowed!? :? .encrypted? .decrypted? encrypted:? decrypted:? providers are:
InnerClasses Encoder Decoder? %java/lang/invoke/MethodHandles$Lookup? java/lang/invoke/MethodHandles Lookup ! % 3 B C + , 3 0 / 0 6 7 > ? 5 0 6 7 0 6 8 0 6 9 0 6 : <