Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provider behavior fixes #102

Merged
merged 2 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ScosslCommon/src/scossl_aes_aead.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ SCOSSL_STATUS scossl_aes_gcm_cipher(SCOSSL_CIPHER_GCM_CTX *ctx, INT32 encrypt,
{
// Auth Data Passed in
SymCryptGcmAuthPart(&ctx->state, in, inl);
*outl = 0;
*outl = inl;
return SCOSSL_SUCCESS;
}

Expand Down Expand Up @@ -638,7 +638,7 @@ SCOSSL_STATUS scossl_aes_ccm_cipher(SCOSSL_CIPHER_CCM_CTX *ctx, INT32 encrypt,
if (out == NULL)
{
// Auth Data Passed in
*outl = 0;
*outl = cbAuthdata;
return SCOSSL_SUCCESS;
}
}
Expand Down
16 changes: 16 additions & 0 deletions ScosslCommon/src/scossl_ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,15 @@ static SCOSSL_STATUS scossl_ecdsa_remove_der(_In_reads_bytes_(cbDerSignature) PC
goto cleanup;
}

if (pbS + cbS != pbSeq + cbSeq)
{
SCOSSL_LOG_ERROR(SCOSSL_ERR_F_ECDSA_REMOVE_DER, ERR_R_PASSED_INVALID_ARGUMENT,
"Unexpected value in sequence");
SCOSSL_LOG_BYTES_DEBUG(SCOSSL_ERR_F_ECDSA_REMOVE_DER, ERR_R_PASSED_INVALID_ARGUMENT,
"pbDerSignature", pbDerSignature, cbDerSignature);
goto cleanup;
}

// Check R's validity
if (((pbR[0] & 0x80) == 0x80) || // R is negative
((cbR > 1) && (pbR[0] == 0x00) && ((pbR[1] & 0x80) != 0x80))) // R is non-zero, and has a redundant leading 0 byte
Expand Down Expand Up @@ -412,6 +421,13 @@ static SCOSSL_STATUS scossl_ecdsa_remove_der(_In_reads_bytes_(cbDerSignature) PC
return res;
}

/*
ECDSA-Sig-Value ::= SEQUENCE {
r INTEGER,
s INTEGER
}
*/

// Quick hack function to generate precisely the DER encodings which we want for ECDSA signatures for the NIST prime curves
// Takes 2 same-size big-endian integers output from SymCrypt and encodes them in the minimally sized (strict) equivalent DER encoding
// Returns SCOSSL_SUCCESS on success, or SCOSSL_FAILURE on failure.
Expand Down