/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
void
rsaBlind_Print(PRUint8* m, size_t t)
{ for (int i = 0; i < t; i++) { if (i % 16 == 0)
printf("\n");
printf("%02x ", m[i]);
}
printf("\n \n");
}
void
mp_print_buf(mp_int* mp)
{ for (int i = MP_USED(mp) - 1; i >= 0; i--) { if (i % 2 == 1)
printf("\n");
printf("%016lx ", (longunsignedint)MP_DIGIT(mp, i));
}
printf("\n \n");
} #endif
/* * 4.1. Prepare * There are two types of preparation functions: * an identity preparation function, and a randomized preparation function. * The identity preparation function returns the input message without transformation, * i.e., msg = PrepareIdentity(msg). * The randomized preparation function augments the input message with fresh randomness. * * Inputs: * - msg, message to be signed, a byte string * * Outputs: * - input_msg, a byte string that is 32 bytes longer than msg
/* RSA Blind Signatures * Blind(pkS, msg) * Parameters: * - kLen, the length in bytes of the RSA modulus n * - Hash, the hash function used to hash the message * - MGF, the mask generation function * - sLen, the length in bytes of the salt * * Inputs: * - pkS, server public key (n, e) * - msg, message to be signed, a byte string * * Outputs: * - blinded_msg, a byte string of length kLen * - inv, an integer used to unblind the signature in Finalize
*/
/* The length of the random buffer is n. */
SECStatus
RSABlinding_Blind(HASH_HashType hashAlg, PRUint8* blindedMsg, size_t blindedMsgLen,
PRUint8* inv, size_t invLen, const PRUint8* msg, size_t msgLen, const PRUint8* salt, size_t saltLen,
RSAPublicKey* pkS, const PRUint8* randomBuf, size_t randomBufLen)
{ if (!blindedMsgLen || !inv || !msg || !pkS) {
PORT_SetError(SEC_ERROR_INVALID_ARGS); return SECFailure;
}
/* 2. If EMSA-PSS-ENCODE raises an error, raise the error and stop. */ if (rv != SECSuccess) {
PORT_SetError(SEC_ERROR_FAILED_TO_ENCODE_DATA); goto cleanup;
}
if (err) {
MP_TO_SEC_ERROR(err); return SECFailure;
}
return rv;
}
/* 4.3. BlindSign * BlindSign(skS, blinded_msg) * * Parameters: * - kLen, the length in bytes of the RSA modulus n * * Inputs: * - skS, server private key * - blinded_msg, encoded and blinded message to be signed, a byte string
*/
if (err) {
MP_TO_SEC_ERROR(err); return SECFailure;
} if (rv != SECSuccess) { return SECFailure;
}
return SECSuccess;
}
/* * 4.4. Finalize. * Finalize validates the server's response, unblinds the message to produce a signature, * verifies it for correctness, and outputs the signature upon success. * * Parameters: * - kLen, the length in bytes of the RSA modulus n * - Hash, the hash function used to hash the message * - MGF, the mask generation function * - sLen, the length in bytes of the salt * * Inputs: * - pkS, server public key (n, e) * - msg, message to be signed, a byte string * - blind_sig, signed and blinded element, a byte string of * length kLen * - inv, inverse of the blind, an integer * * Outputs: * - sig, a byte string of length kLen * * Blinded Signature Len should be the same as modulus len.
*/
/* 5. result = RSASSA-PSS-VERIFY(pkS, msg, sig) with Hash, MGF, and sLen as defined in the parameters. */
rv = RSA_CheckSignPSS(pkS, hashAlg, hashAlg, saltLen, signature, sig_mp.used * MP_DIGIT_BYTE, mHash, 0);
/* If result = "valid signature", output sig, else raise "invalid signature" and stop. */ if (rv != SECSuccess) {
PORT_SetError(SEC_ERROR_BAD_SIGNATURE);
}
#ifdef RSA_DEBUG if (rv == SECFailure) {
printf("%s\n", "RSA CheckSignPSS has failed. ");
} else {
printf("%s\n", "RSA CheckSignPSS has succeeded. ");
} #endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.