|
23 | 23 | import java.io.File; |
24 | 24 | import java.io.IOException; |
25 | 25 | import java.nio.charset.Charset; |
| 26 | +import java.util.Arrays; |
26 | 27 | import java.security.PublicKey; |
27 | 28 | import java.security.PrivateKey; |
28 | 29 | import java.security.interfaces.RSAPublicKey; |
@@ -634,7 +635,11 @@ public void signRequest(String filePath, int keyType, int format, |
634 | 635 | "Failed to read bytes from file: " + filePath); |
635 | 636 | } |
636 | 637 |
|
637 | | - signRequest(fileBytes, keyType, format, digestAlg); |
| 638 | + try { |
| 639 | + signRequest(fileBytes, keyType, format, digestAlg); |
| 640 | + } finally { |
| 641 | + Arrays.fill(fileBytes, (byte)0); |
| 642 | + } |
638 | 643 | } |
639 | 644 |
|
640 | 645 | /** |
@@ -751,9 +756,13 @@ else if (key instanceof ECPrivateKey) { |
751 | 756 | throw new WolfSSLException("PrivateKey does not support encoding"); |
752 | 757 | } |
753 | 758 |
|
754 | | - synchronized (x509ReqLock) { |
755 | | - ret = X509_REQ_sign(this.x509ReqPtr, evpKeyType, encodedKey, |
756 | | - WolfSSL.SSL_FILETYPE_ASN1, digestAlg); |
| 759 | + try { |
| 760 | + synchronized (x509ReqLock) { |
| 761 | + ret = X509_REQ_sign(this.x509ReqPtr, evpKeyType, encodedKey, |
| 762 | + WolfSSL.SSL_FILETYPE_ASN1, digestAlg); |
| 763 | + } |
| 764 | + } finally { |
| 765 | + Arrays.fill(encodedKey, (byte)0); |
757 | 766 | } |
758 | 767 |
|
759 | 768 | if (ret != WolfSSL.SSL_SUCCESS) { |
|
0 commit comments