22
33import net .sharksystem .asap .ASAPException ;
44import net .sharksystem .asap .ASAPSecurityException ;
5- import net .sharksystem .crypto .BasicCryptoParameters ;
5+ import net .sharksystem .crypto .BasicKeyStore ;
66import net .sharksystem .crypto .ASAPCryptoAlgorithms ;
77import net .sharksystem .utils .ASAPSerialization ;
88
@@ -12,7 +12,7 @@ class ASAPCryptoMessage {
1212 private boolean encrypted ;
1313 private boolean sign ;
1414 private CharSequence recipient ;
15- private BasicCryptoParameters basicCryptoParameters ;
15+ private BasicKeyStore basicKeyStore ;
1616 private byte cmd ;
1717
1818 private OutputStream effectiveOS ;
@@ -21,26 +21,26 @@ class ASAPCryptoMessage {
2121 private InputStreamCopy inputStreamCopy ;
2222 private ASAPCryptoAlgorithms .EncryptedMessagePackage encryptedMessagePackage ;
2323
24- ASAPCryptoMessage (BasicCryptoParameters basicCryptoParameters ) {
25- this .basicCryptoParameters = basicCryptoParameters ;
24+ ASAPCryptoMessage (BasicKeyStore basicKeyStore ) {
25+ this .basicKeyStore = basicKeyStore ;
2626 }
2727
2828 ASAPCryptoMessage (byte cmd , OutputStream os , boolean sign , boolean encrypted ,
2929 CharSequence recipient ,
30- BasicCryptoParameters basicCryptoParameters )
30+ BasicKeyStore basicKeyStore )
3131 throws ASAPSecurityException {
3232
3333 this .cmd = cmd ;
3434 this .realOS = os ;
3535 this .effectiveOS = os ; // still this one
36- this .basicCryptoParameters = basicCryptoParameters ;
36+ this .basicKeyStore = basicKeyStore ;
3737 this .recipient = recipient ;
3838 this .encrypted = encrypted ;
3939 this .sign = sign ;
4040
4141 if (encrypted || sign ) {
4242 // we need some basic crypto parameters
43- if (basicCryptoParameters == null ) {
43+ if (basicKeyStore == null ) {
4444 throw new ASAPSecurityException ("cannot encrypt or sign without cryptp parameters / key store" );
4545 }
4646 this .setupCopyOutputStream ();
@@ -56,7 +56,7 @@ class ASAPCryptoMessage {
5656
5757 if (sign ) {
5858 // signing needs a private key - check of available
59- if (basicCryptoParameters .getPrivateKey () == null ) {
59+ if (basicKeyStore .getPrivateKey () == null ) {
6060 throw new ASAPSecurityException ("asap message is to be signed but no private key - fatal, give up" );
6161 }
6262 }
@@ -85,7 +85,7 @@ public void finish() throws ASAPSecurityException {
8585 // get message as bytes
8686 byte [] asapMessageAsBytes = this .outputStreamCopy .toByteArray ();
8787 // produce signature
88- byte [] signatureBytes = ASAPCryptoAlgorithms .sign (asapMessageAsBytes , this .basicCryptoParameters );
88+ byte [] signatureBytes = ASAPCryptoAlgorithms .sign (asapMessageAsBytes , this .basicKeyStore );
8989
9090 if (this .encrypted ) {
9191 // have to store it - message and signature will be encrypted
@@ -105,7 +105,7 @@ public void finish() throws ASAPSecurityException {
105105 byte [] asapMessageAsBytes = this .outputStreamCopy .toByteArray ();
106106
107107 ASAPCryptoAlgorithms .writeEncryptedMessagePackage (
108- asapMessageAsBytes , this .recipient , this .basicCryptoParameters , this .realOS );
108+ asapMessageAsBytes , this .recipient , this .basicKeyStore , this .realOS );
109109 }
110110 }
111111
@@ -159,7 +159,7 @@ public boolean verify(String sender, InputStream is) throws IOException, ASAPExc
159159 byte [] signatureBytes = ASAPSerialization .readByteArray (is );
160160 // debug break
161161 boolean wasVerified =
162- ASAPCryptoAlgorithms .verify (signedData , signatureBytes , sender , this .basicCryptoParameters );
162+ ASAPCryptoAlgorithms .verify (signedData , signatureBytes , sender , this .basicKeyStore );
163163
164164 return wasVerified ;
165165 }
@@ -185,12 +185,12 @@ public boolean initDecryption(byte cmd, InputStream is) throws IOException, ASAP
185185 ASAPCryptoAlgorithms .parseEncryptedMessagePackage (is );
186186 // ASAPCryptoAlgorithms.parseEncryptedMessagePackage(copyStream);
187187
188- if (this .basicCryptoParameters == null ) {
188+ if (this .basicKeyStore == null ) {
189189 System .out .println (this .getLogStart () + "no keystore set: cannot handle encrypted messages" );
190190 return false ;
191191 }
192192
193- if (this .basicCryptoParameters .isOwner (this .encryptedMessagePackage .getRecipient ())) {
193+ if (this .basicKeyStore .isOwner (this .encryptedMessagePackage .getRecipient ())) {
194194 return true ;
195195 }
196196
@@ -215,7 +215,7 @@ public InputStream doDecryption() throws ASAPSecurityException {
215215 }
216216
217217 byte [] decryptedBytes =
218- ASAPCryptoAlgorithms .decryptPackage (this .encryptedMessagePackage , this .basicCryptoParameters );
218+ ASAPCryptoAlgorithms .decryptPackage (this .encryptedMessagePackage , this .basicKeyStore );
219219
220220 return new ByteArrayInputStream (decryptedBytes );
221221 }
0 commit comments