Browse Source

z/OS support: char -> uint8_t

master
David Lanzendörfer 1 year ago
parent
commit
860a703fdd
1 changed files with 18 additions and 26 deletions
  1. +18
    -26
      src/create.c

+ 18
- 26
src/create.c View File

@ -145,7 +145,7 @@ pgp_fast_create_userid(uint8_t **id, uint8_t *userid)
* \return 1 if OK, otherwise 0
*/
unsigned
pgp_write_struct_userid(pgp_output_t *output, const unsigned char *id)
pgp_write_struct_userid(pgp_output_t *output, const uint8_t*id)
{
return pgp_write_ptag(output, PGP_PTAG_CT_USER_ID) &&
pgp_write_length(output, (unsigned)strlen((const char *) id)) &&
@ -161,7 +161,7 @@ pgp_write_struct_userid(pgp_output_t *output, const unsigned char *id)
* \return return value from pgp_write_struct_userid()
*/
unsigned
pgp_write_userid(const char *userid, pgp_output_t *output)
pgp_write_userid(const uint8_t *userid, pgp_output_t *output)
{
return pgp_write_struct_userid(output, userid);
}
@ -169,22 +169,20 @@ pgp_write_userid(const char *userid, pgp_output_t *output)
/**
\ingroup Core_MPI
*/
#ifdef HAVE_OPENSSL
#if defined(HAVE_OPENSSL)
static unsigned
mpi_length(const BIGNUM *bn)
{
return (unsigned)(2 + (BN_num_bits(bn) + 7) / 8);
}
#endif
#ifdef HAVE_GSKSSL
#elif defined(HAVE_GSKSSL)
static unsigned
mpi_length(gsk_buffer bn)
mpi_length(gsk_buffer *bn)
{
return (unsigned)(2 + (bn.length*8 + 7) / 8);
return (unsigned)(2 + ( (bn->length*8-1) + 7) / 8);
}
#endif
static unsigned
pubkey_length(const pgp_pubkey_t *key)
{
@ -311,7 +309,6 @@ write_seckey_body(const pgp_seckey_t *key,
pgp_output_t *output)
{
/* RFC4880 Section 5.5.3 Secret-Key Packet Formats */
pgp_crypt_t crypted;
pgp_hash_t hash;
unsigned done = 0;
@ -560,7 +557,7 @@ pgp_write_xfer_key(pgp_output_t *output,
pgp_directsig_t *directsigp;
unsigned uididx = 0;
unsigned uidsigidx = 0;
unsigned char **uidp;
uint8_t **uidp;
pgp_uidsig_t *uidsigp;
pgp_subkey_t *subkeyp;
unsigned subkeyidx = 0;
@ -586,8 +583,7 @@ pgp_write_xfer_key(pgp_output_t *output,
for (directsigidx = 0 ; directsigidx < key->directsigc;
directsigidx++, directsigp++)
{
if (!pgp_write(output, directsigp->packet.raw,
(unsigned)directsigp->packet.length)) {
if (!pgp_write(output, directsigp->packet.raw, (unsigned)directsigp->packet.length)) {
return 0;
}
}
@ -606,8 +602,7 @@ pgp_write_xfer_key(pgp_output_t *output,
/* matching selected user id */
if(uidsigp->uid == uididx)
{
if (!pgp_write(output, uidsigp->packet.raw,
(unsigned)uidsigp->packet.length)) {
if (!pgp_write(output, uidsigp->packet.raw, (unsigned)uidsigp->packet.length)) {
return 0;
}
}
@ -643,8 +638,7 @@ pgp_write_xfer_key(pgp_output_t *output,
/* matching selected subkey */
if(subkeysigp->subkey == subkeyidx)
{
if (!pgp_write(output, subkeysigp->packet.raw,
(unsigned)subkeysigp->packet.length)) {
if (!pgp_write(output, subkeysigp->packet.raw, (unsigned)subkeysigp->packet.length)) {
return 0;
}
}
@ -916,7 +910,7 @@ encode_m_buf(const uint8_t *M, size_t mLen, const pgp_pubkey_t * pubkey,
k = (unsigned)BN_num_bytes(pubkey->key.rsa.n);
#endif
#ifdef HAVE_GSKSSL
k = (unsigned)pubkey->key.rsa.n.length;
k = (unsigned)pubkey->key.rsa.n->length;
#endif
if (mLen > k - 11) {
(void) fprintf(stderr, "encode_m_buf: message too long\n");
@ -929,7 +923,7 @@ encode_m_buf(const uint8_t *M, size_t mLen, const pgp_pubkey_t * pubkey,
k = (unsigned)BN_num_bytes(pubkey->key.elgamal.p);
#endif
#ifdef HAVE_GSKSSL
k = pubkey->key.elgamal.p.length;
k = pubkey->key.elgamal.p->length;
#endif
if (mLen > k - 11) {
(void) fprintf(stderr, "encode_m_buf: message too long\n");
@ -979,7 +973,6 @@ pgp_create_pk_sesskey(pgp_key_t *key, const char *ciphername, pgp_pk_sesskey_t *
* Encryption used is PK,
* can be any, we're hardcoding RSA for now
*/
printf("%s\n",__FUNCTION__);
pgp_pubkey_t *pubkey;
pgp_pk_sesskey_t *sesskey;
pgp_symm_alg_t cipher;
@ -1005,7 +998,7 @@ pgp_create_pk_sesskey(pgp_key_t *key, const char *ciphername, pgp_pk_sesskey_t *
#if defined(HAVE_OPENSSL)
sz_encoded_m_buf = BN_num_bytes(pubkey->key.rsa.n);
#elif defined(HAVE_GSKSSL)
sz_encoded_m_buf = pubkey->key.rsa.n.length;
sz_encoded_m_buf = pubkey->key.rsa.n->length;
#endif
break;
case PGP_PKA_DSA:
@ -1013,7 +1006,7 @@ pgp_create_pk_sesskey(pgp_key_t *key, const char *ciphername, pgp_pk_sesskey_t *
#if defined(HAVE_OPENSSL)
sz_encoded_m_buf = BN_num_bytes(pubkey->key.elgamal.p);
#elif defined(HAVE_GSKSSL)
sz_encoded_m_buf = pubkey->key.elgamal.p.length;
sz_encoded_m_buf = pubkey->key.elgamal.p->length;
#endif
break;
default:
@ -1127,7 +1120,6 @@ pgp_create_pk_sesskey(pgp_key_t *key, const char *ciphername, pgp_pk_sesskey_t *
unsigned
pgp_write_pk_sesskey(pgp_output_t *output, pgp_pk_sesskey_t *pksk)
{
printf("%s\n",__FUNCTION__);
/* XXX - Flexelint - Pointer parameter 'pksk' (line 1076) could be declared as pointing to const */
if (pksk == NULL) {
(void) fprintf(stderr,
@ -1141,7 +1133,7 @@ pgp_write_pk_sesskey(pgp_output_t *output, pgp_pk_sesskey_t *pksk)
#if defined(HAVE_OPENSSL)
BN_num_bytes(pksk->params.rsa.encrypted_m)
#elif defined(HAVE_GSKSSL)
pksk->params.rsa.encrypted_m.length
pksk->params.rsa.encrypted_m->length
#endif
+ 2)) &&
pgp_write_scalar(output, (unsigned)pksk->version, 1) &&
@ -1158,13 +1150,13 @@ pgp_write_pk_sesskey(pgp_output_t *output, pgp_pk_sesskey_t *pksk)
#if defined(HAVE_OPENSSL)
BN_num_bytes(pksk->params.elgamal.g_to_k)
#elif defined(HAVE_GSKSSL)
pksk->params.elgamal.g_to_k.length
pksk->params.elgamal.g_to_k->length
#endif
+ 2 +
#if defined(HAVE_OPENSSL)
BN_num_bytes(pksk->params.elgamal.encrypted_m)
#elif defined(HAVE_GSKSSL)
pksk->params.elgamal.encrypted_m.length
pksk->params.elgamal.encrypted_m->length
#endif
+ 2)) &&
pgp_write_scalar(output, (unsigned)pksk->version, 1) &&
@ -1354,7 +1346,7 @@ pgp_write_one_pass_sig(pgp_output_t *output,
const pgp_hash_alg_t hash_alg,
const pgp_sig_type_t sig_type)
{
uint8_t keyid[PGP_KEY_ID_SIZE];
uint8_t keyid[PGP_KEY_ID_SIZE];
pgp_keyid(keyid, PGP_KEY_ID_SIZE, &seckey->pubkey, PGP_HASH_SHA1); /* XXX - hardcoded */
return pgp_write_ptag(output, PGP_PTAG_CT_1_PASS_SIG) &&


Loading…
Cancel
Save