File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
pg/src/main/java/org/bouncycastle/openpgp Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ public class PGPEncryptedDataGenerator
89
89
// If true, force generation of a session key, even if we only have a single password-based encryption method
90
90
// and could therefore use the S2K output as session key directly.
91
91
private boolean forceSessionKey = true ;
92
+ private SessionKeyExtractionCallback sessionKeyExtractionCallback = null ;
92
93
93
94
/**
94
95
* Base constructor.
@@ -178,6 +179,11 @@ private byte[] createSessionInfo(
178
179
return sessionInfo ;
179
180
}
180
181
182
+ public void setSessionKeyExtractionCallback (SessionKeyExtractionCallback callback )
183
+ {
184
+ this .sessionKeyExtractionCallback = callback ;
185
+ }
186
+
181
187
/**
182
188
* Create an OutputStream based on the configured methods.
183
189
* <p>
@@ -252,6 +258,11 @@ else if (directS2K)
252
258
messageKey = sessionKey ;
253
259
}
254
260
261
+ if (sessionKeyExtractionCallback != null )
262
+ {
263
+ sessionKeyExtractionCallback .extractSessionKey (new PGPSessionKey (defAlgorithm , sessionKey ));
264
+ }
265
+
255
266
PGPDataEncryptor dataEncryptor = dataEncryptorBuilder .build (messageKey );
256
267
digestCalc = dataEncryptor .getIntegrityCalculator ();
257
268
@@ -579,4 +590,9 @@ public void close()
579
590
this .finish ();
580
591
}
581
592
}
593
+
594
+ public interface SessionKeyExtractionCallback
595
+ {
596
+ void extractSessionKey (PGPSessionKey sessionKey );
597
+ }
582
598
}
You can’t perform that action at this time.
0 commit comments