mirror of
https://github.com/php-gnupg/php-gnupg.git
synced 2024-11-22 14:27:09 +00:00
Fix CS in gnupg_verify
This commit is contained in:
parent
91f392fa9f
commit
0e92c34de0
1 changed files with 13 additions and 8 deletions
21
gnupg.c
21
gnupg.c
|
@ -1332,49 +1332,54 @@ PHP_FUNCTION(gnupg_verify)
|
||||||
GNUPG_GETOBJ();
|
GNUPG_GETOBJ();
|
||||||
|
|
||||||
if (this) {
|
if (this) {
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z", &signed_text, &signature, &plain_text) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z",
|
||||||
|
&signed_text, &signature, &plain_text) == FAILURE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rzz|z", &res, &signed_text, &signature, &plain_text) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rzz|z",
|
||||||
|
&res, &signed_text, &signature, &plain_text) == FAILURE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GNUPG_RES_FETCH();
|
GNUPG_RES_FETCH();
|
||||||
}
|
}
|
||||||
if (Z_TYPE_P(signature) == IS_STRING) { /* detached signature */
|
if (Z_TYPE_P(signature) == IS_STRING) { /* detached signature */
|
||||||
/* setup signature-databuffer for gpgme */
|
/* setup signature-databuffer for gpgme */
|
||||||
if ((PHPC_THIS->err = gpgme_data_new_from_mem(&gpgme_sig, Z_STRVAL_P(signature), Z_STRLEN_P(signature), 0)) != GPG_ERR_NO_ERROR) {
|
if (!PHP_GNUPG_DO(gpgme_data_new_from_mem(
|
||||||
|
&gpgme_sig, Z_STRVAL_P(signature), Z_STRLEN_P(signature), 0))) {
|
||||||
GNUPG_ERR("could not create signature-databuffer");
|
GNUPG_ERR("could not create signature-databuffer");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* and the text */
|
/* and the text */
|
||||||
if ((PHPC_THIS->err = gpgme_data_new_from_mem(&gpgme_text, Z_STRVAL_P(signed_text), Z_STRLEN_P(signed_text), 0)) != GPG_ERR_NO_ERROR) {
|
if (!PHP_GNUPG_DO(gpgme_data_new_from_mem(
|
||||||
|
&gpgme_text, Z_STRVAL_P(signed_text), Z_STRLEN_P(signed_text), 0))) {
|
||||||
GNUPG_ERR("could not create text-databuffer");
|
GNUPG_ERR("could not create text-databuffer");
|
||||||
gpgme_data_release(gpgme_sig);
|
gpgme_data_release(gpgme_sig);
|
||||||
gpgme_data_release(gpgme_text);
|
gpgme_data_release(gpgme_text);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* now verify sig + text */
|
/* now verify sig + text */
|
||||||
if ((PHPC_THIS->err = gpgme_op_verify (PHPC_THIS->ctx, gpgme_sig, gpgme_text, NULL)) != GPG_ERR_NO_ERROR) {
|
if (!PHP_GNUPG_DO(gpgme_op_verify(PHPC_THIS->ctx, gpgme_sig, gpgme_text, NULL))) {
|
||||||
GNUPG_ERR("verify failed");
|
GNUPG_ERR("verify failed");
|
||||||
gpgme_data_release(gpgme_sig);
|
gpgme_data_release(gpgme_sig);
|
||||||
gpgme_data_release(gpgme_text);
|
gpgme_data_release(gpgme_text);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else { /* clearsign or normal signature */
|
} else { /* clearsign or normal signature */
|
||||||
if ((PHPC_THIS->err = gpgme_data_new_from_mem(&gpgme_sig, Z_STRVAL_P(signed_text), Z_STRLEN_P(signed_text), 0)) != GPG_ERR_NO_ERROR) {
|
if (!PHP_GNUPG_DO(gpgme_data_new_from_mem(
|
||||||
|
&gpgme_sig, Z_STRVAL_P(signed_text), Z_STRLEN_P(signed_text), 0))) {
|
||||||
GNUPG_ERR("could not create signature-databuffer");
|
GNUPG_ERR("could not create signature-databuffer");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* set a NULL databuffer for gpgme */
|
/* set a NULL databuffer for gpgme */
|
||||||
if ((PHPC_THIS->err = gpgme_data_new_from_mem(&gpgme_text, NULL, 0, 0)) != GPG_ERR_NO_ERROR) {
|
if (!PHP_GNUPG_DO(gpgme_data_new_from_mem(&gpgme_text, NULL, 0, 0))) {
|
||||||
GNUPG_ERR("could not create text-databuffer");
|
GNUPG_ERR("could not create text-databuffer");
|
||||||
gpgme_data_release(gpgme_sig);
|
gpgme_data_release(gpgme_sig);
|
||||||
gpgme_data_release(gpgme_text);
|
gpgme_data_release(gpgme_text);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* and verify the 'signature' */
|
/* and verify the 'signature' */
|
||||||
if ((PHPC_THIS->err = gpgme_op_verify(PHPC_THIS->ctx, gpgme_sig, NULL, gpgme_text)) != GPG_ERR_NO_ERROR) {
|
if (!PHP_GNUPG_DO(gpgme_op_verify(PHPC_THIS->ctx, gpgme_sig, NULL, gpgme_text))) {
|
||||||
GNUPG_ERR("verify failed");
|
GNUPG_ERR("verify failed");
|
||||||
gpgme_data_release(gpgme_sig);
|
gpgme_data_release(gpgme_sig);
|
||||||
gpgme_data_release(gpgme_text);
|
gpgme_data_release(gpgme_text);
|
||||||
|
|
Loading…
Reference in a new issue