futility/cmd_sign.c
/* This wraps/signs a public key, producing a keyblock. */
This wraps/signs a public key, producing a keyblock.
This wraps / signs a public key producing a keyblock .
int ft_sign_pubkey(const char *name, uint8_t *buf, uint32_t len, void *data)
{
	struct vb2_packed_key *data_key = (struct vb2_packed_key *)buf;
	struct vb2_keyblock *block;
	if (vb2_packed_key_looks_ok(data_key, len)) {
		fprintf(stderr, "Public key looks bad.\n");
		return 1;
	}
	if (sign_option.pem_signpriv) {
		if (sign_option.pem_external) {
			block = vb2_create_keyblock_external(
				data_key,
				sign_option.pem_signpriv,
				sign_option.pem_algo,
				sign_option.flags,
				sign_option.pem_external);
		} else {
			sign_option.signprivate = vb2_read_private_key_pem(
				sign_option.pem_signpriv,
				sign_option.pem_algo);
			if (!sign_option.signprivate) {
				fprintf(stderr,
					"Unable to read PEM signing key: %s\n",
					strerror(errno));
				return 1;
			}
			block = vb2_create_keyblock(data_key,
						    sign_option.signprivate,
						    sign_option.flags);
		}
	} else {
		block = vb2_create_keyblock(data_key, sign_option.signprivate,
					    sign_option.flags);
	}
	return WriteSomeParts(sign_option.outfile,
			      block, block->keyblock_size,
			      NULL, 0);
}
int ft_sign_pubkey ( const char * name , uint8_t * buf , uint32_t len , void * data ) { struct vb2_packed_key * data_key = ( struct vb2_packed_key * ) buf ; struct vb2_keyblock * block ; if ( vb2_packed_key_looks_ok ( data_key , len ) ) { fprintf ( stderr , " \n " ) ; return 1 ; } if ( sign_option . pem_signpriv ) { if ( sign_option . pem_external ) { block = vb2_create_keyblock_external ( data_key , sign_option . pem_signpriv , sign_option . pem_algo , sign_option . flags , sign_option . pem_external ) ; } else { sign_option . signprivate = vb2_read_private_key_pem ( sign_option . pem_signpriv , sign_option . pem_algo ) ; if ( ! sign_option . signprivate ) { fprintf ( stderr , " \n " , strerror ( errno ) ) ; return 1 ; } block = vb2_create_keyblock ( data_key , sign_option . signprivate , sign_option . flags ) ; } } else { block = vb2_create_keyblock ( data_key , sign_option . signprivate , sign_option . flags ) ; } return WriteSomeParts ( sign_option . outfile , block , block -> keyblock_size , NULL , 0 ) ; }
This wraps/signs a public key, producing a keyblock.
This wraps / signs a public key producing a keyblock .
/* External signing uses the PEM file directly. */ /* Not PEM. Should already have a signing key. */ /* Write it out */