Skip to content

Commit

Permalink
make logic more clear
Browse files Browse the repository at this point in the history
  • Loading branch information
qmuntal committed Sep 4, 2024
1 parent 554252b commit b858b65
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions rsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,15 @@ func newRSAKey3(isPriv bool, N, E, D, P, Q, Dp, Dq, Qinv BigInt) (C.GO_EVP_PKEY_
}
comps = append(comps, required[:]...)

// OpenSSL 3.0 and 3.1 required all the precomputed values if
// P and Q are present. See:
// https://github.com/openssl/openssl/pull/22334
if vMinor >= 2 || (P != nil && Q != nil && Dp != nil && Dq != nil && Qinv != nil) {
if P != nil && Q != nil {
if P != nil && Q != nil {
allPrecomputedExists := Dp != nil && Dq != nil && Qinv != nil
// OpenSSL 3.0 and 3.1 required all the precomputed values if
// P and Q are present. If they are not, we need to omit also P and Q.
// See https://github.com/openssl/openssl/pull/22334
if vMinor >= 2 || allPrecomputedExists {
comps = append(comps, bigIntParam{paramRSA_P, P}, bigIntParam{paramRSA_Q, Q})
}
if Dp != nil && Dq != nil && Qinv != nil {
if allPrecomputedExists {
comps = append(comps,
bigIntParam{paramRSA_Dp, Dp},
bigIntParam{paramRSA_Dq, Dq},
Expand Down

0 comments on commit b858b65

Please sign in to comment.