Skip to content

Commit 84bbd79

Browse files
committed
update SignatureAlgorithm
Signed-off-by: alperozturk <[email protected]>
1 parent 71bb367 commit 84bbd79

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

library/src/main/java/com/owncloud/android/lib/resources/e2ee/CsrHelper.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,16 @@ class CsrHelper {
3838
*
3939
* @param keyPair the KeyPair with private and public keys
4040
* @param userId userId of CSR owner
41-
* @param algorithm represents supported signature algorithm
4241
* @return PEM encoded CSR string
4342
* @throws IOException thrown if key cannot be created
4443
* @throws OperatorCreationException thrown if contentSigner cannot be build
4544
*/
4645
@Throws(IOException::class, OperatorCreationException::class)
4746
fun generateCsrPemEncodedString(
4847
keyPair: KeyPair,
49-
userId: String,
50-
algorithm: SignatureAlgorithm
48+
userId: String
5149
): String {
52-
val csr = generateCSR(keyPair, userId, algorithm)
50+
val csr = generateCSR(keyPair, userId)
5351
val derCSR = csr.encoded
5452
return "-----BEGIN CERTIFICATE REQUEST-----\n" +
5553
Base64.encodeToString(
@@ -63,7 +61,6 @@ class CsrHelper {
6361
*
6462
* @param keyPair the KeyPair with private and public keys
6563
* @param userId userId of CSR owner
66-
* @param algorithm represents supported signature algorithm
6764
* @return PKCS10CertificationRequest with the certificate signing request (CSR) data
6865
* @throws IOException thrown if key cannot be created
6966
* @throws OperatorCreationException thrown if contentSigner cannot be build
@@ -73,12 +70,12 @@ class CsrHelper {
7370
private fun generateCSR(
7471
keyPair: KeyPair,
7572
userId: String,
76-
algorithm: SignatureAlgorithm
7773
): PKCS10CertificationRequest {
7874
val principal = "CN=$userId"
75+
7976
val privateKey = PrivateKeyFactory.createKey(keyPair.private.encoded)
80-
val signatureAlgorithm = DefaultSignatureAlgorithmIdentifierFinder().find(algorithm.signatureAlg)
81-
val digestAlgorithm = DefaultDigestAlgorithmIdentifierFinder().find(algorithm.digestAlg)
77+
val signatureAlgorithm = DefaultSignatureAlgorithmIdentifierFinder().find(SignatureAlgorithm.SHA256.signatureAlg)
78+
val digestAlgorithm = DefaultDigestAlgorithmIdentifierFinder().find(SignatureAlgorithm.SHA256.digestAlg)
8279
val signer =
8380
BcRSAContentSignerBuilder(signatureAlgorithm, digestAlgorithm).build(privateKey)
8481
val csrBuilder: PKCS10CertificationRequestBuilder =

library/src/main/java/com/owncloud/android/lib/resources/e2ee/SignatureAlgorithm.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ enum class SignatureAlgorithm(
1111
val signatureAlg: String,
1212
val digestAlg: String
1313
) {
14-
SHA256("SHA256WITHRSA", "SHA-256")
14+
SHA256("SHA256WITHRSAENCRYPTION", "SHA-256")
1515
}

0 commit comments

Comments
 (0)