static int do_rsa_verify(struct verifier *v, int algorithm, UINT32 length, const UINT8 *msg, UINT32 signature_length, const UINT8 *signature_data) { CAST(rsa_verifier, self, v); mpz_t s; int res = 0; trace("do_rsa_verify: Verifying %a signature\n", algorithm); mpz_init(s); switch(algorithm) { #if 0 case ATOM_RSA_PKCS1_SHA1: case ATOM_RSA_PKCS1_SHA1_LOCAL: if (signature_length > self->size) goto fail; bignum_parse_u(s, signature_length, signature_data); break; case ATOM_SPKI: #endif case ATOM_SSH_RSA: { struct simple_buffer buffer; UINT32 length; const UINT8 *digits; int atom; simple_buffer_init(&buffer, signature_length, signature_data); if (!(parse_atom(&buffer, &atom) && (atom == ATOM_SSH_RSA) && parse_string(&buffer, &length, &digits) && (length <= self->size) && parse_eod(&buffer) )) goto fail; bignum_parse_u(s, length, digits); break; } /* It doesn't matter here which flavour of SPKI is used. */ case ATOM_SPKI_SIGN_RSA: case ATOM_SPKI_SIGN_DSS: { struct simple_buffer buffer; struct sexp *e; simple_buffer_init(&buffer, signature_length, signature_data); if (! ( (e = sexp_parse_canonical(&buffer)) && parse_eod(&buffer) && decode_rsa_sig_val(e, s, self->size)) ) goto fail; break; } default: fatal("do_rsa_verify: Internal error!\n"); } res = rsa_pkcs1_verify(self, length, msg, s); fail: mpz_clear(s); return res; }
/*! * \brief Set the ramdisk image * * \param bootImage CBootImage object * \param data Byte array containing ramdisk image * \param size Size of byte array * * \sa BootImage::setRamdiskImage() */ void mbp_bootimage_set_ramdisk_image(CBootImage *bootImage, const void *data, size_t size) { CAST(bootImage); bi->setRamdiskImage(data_to_vector(data, size)); }
/*! * \brief Destroys a CBootImage object. * * \param bootImage CBootImage to destroy */ void mbp_bootimage_destroy(CBootImage *bootImage) { CAST(bootImage); delete bi; }
/*! * \brief Resets the second bootloader address field in the header to the * default * * \param bootImage CBootImage object * * \sa BootImage::resetSecondBootloaderAddress() */ void mbp_bootimage_reset_second_bootloader_address(CBootImage *bootImage) { CAST(bootImage); bi->resetSecondBootloaderAddress(); }
/*! * \brief Resets the kernel tags address field in the header to the default * * \param bootImage CBootImage object * * \sa BootImage::resetKernelTagsAddress() */ void mbp_bootimage_reset_kernel_tags_address(CBootImage *bootImage) { CAST(bootImage); bi->resetKernelTagsAddress(); }
/*! * \brief Resets the page size field in the header to the default * * \param bootImage CBootImage object * * \sa BootImage::resetPageSize() */ void mbp_bootimage_reset_page_size(CBootImage *bootImage) { CAST(bootImage); bi->resetPageSize(); }
/*! * \brief Resets the ramdisk address field in the header to the default * * \param bootImage CBootImage object * * \sa BootImage::resetRamdiskAddress() */ void mbp_bootimage_reset_ramdisk_address(CBootImage *bootImage) { CAST(bootImage); bi->resetRamdiskAddress(); }
void Transporter::OnPushToWorld() { // Create waypoint event sEventMgr.AddEvent(CAST(Transporter,this), &Transporter::UpdatePosition, EVENT_TRANSPORTER_NEXT_WAYPOINT, 100, 0,EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); }
/*! * \brief Load boot image from binary data * * \param bootImage CBootImage object * \param data Byte array containing binary data * \param size Size of byte array * * \return true on success or false on failure and error set appropriately * * \sa BootImage::load(const std::vector<unsigned char> &) */ bool mbp_bootimage_load_data(CBootImage *bootImage, const void *data, size_t size) { CAST(bootImage); return bi->load(data_to_vector(data, size)); }
static error_t main_argp_parser(int key, char *arg, struct argp_state *state) { CAST(srp_gen_options, self, state->input); switch(key) { default: return ARGP_ERR_UNKNOWN; case ARGP_KEY_INIT: state->child_inputs[0] = &self->style; state->child_inputs[1] = NULL; break; case ARGP_KEY_END: if (!self->name) argp_error(state, "No user name given. Use the -l option, or set LOGNAME in the environment."); { struct lsh_fd *fd; if (self->file) { fd = io_write_file(self->backend, self->file->data, O_CREAT | O_EXCL | O_WRONLY, 0600, BLOCK_SIZE, NULL, self->e); if (!fd) argp_failure(state, EXIT_FAILURE, errno, "Could not open '%s'.", self->file->data); } else { fd = io_write(make_lsh_fd(self->backend, STDOUT_FILENO, "stdout", self->e), BLOCK_SIZE, NULL); } self->dest = &fd->write_buffer->super; } while (!self->passwd) { struct lsh_string *pw; struct lsh_string *again; pw = INTERACT_READ_PASSWORD(self->tty, 500, ssh_format("Enter new SRP password: "******"Aborted."); again = INTERACT_READ_PASSWORD(self->tty, 500, ssh_format("Again: "), 1); if (!again) argp_failure(state, EXIT_FAILURE, 0, "Aborted."); if (lsh_string_eq(pw, again)) self->passwd = pw; else lsh_string_free(pw); lsh_string_free(again); } if (self->style < 0) self->style = self->file ? SEXP_CANONICAL : SEXP_TRANSPORT; break; case 'o': self->file = make_string(arg); break; case 'p': self->passwd = ssh_format("%lz", arg); break; } return 0; }
int f(s_obj *o) { CAST(o,A); }
GameObject *Object2Deserialize( FILE *fp ) { GameObject *obj = CreateObject( ID_Object2 ); DeserializeInt( &CAST( obj, Object2 )->counter, fp ); return obj; }
void Object2Serialize( GameObject *obj, FILE *fp ) { SerializeInt( obj->id, fp ); SerializeInt( CAST( obj, Object2 )->counter, fp ); }
static struct verifier * do_rsa_get_verifier(struct signer *s) { CAST(rsa_signer, self, s); return &self->verifier->super; }
/*! * \brief Resets the kernel cmdline to the default * * \param bootImage CBootImage object * * \sa BootImage::resetKernelCmdline() */ void mbp_bootimage_reset_kernel_cmdline(CBootImage *bootImage) { CAST(bootImage); bi->resetKernelCmdline(); }
/*! * \brief Load boot image from a file * * \param bootImage CBootImage object * \param filename Path to boot image file * * \return true on success or false on failure and error set appropriately * * \sa BootImage::load(const std::string &) */ bool mbp_bootimage_load_file(CBootImage *bootImage, const char *filename) { CAST(bootImage); return bi->load(filename); }
/*! * \brief Set the page size field in the boot image header * * \param bootImage CBootImage object * \param pageSize Page size * * \sa BootImage::setPageSize() */ void mbp_bootimage_set_page_size(CBootImage *bootImage, uint32_t pageSize) { CAST(bootImage); bi->setPageSize(pageSize); }
/*! * \brief Constructs boot image and writes it to a file * * \param bootImage CBootImage object * \param filename Path to output file * * \return true on success or false on failure and error set appropriately * * \sa BootImage::createFile() */ bool mbp_bootimage_create_file(CBootImage *bootImage, const char *filename) { CAST(bootImage); return bi->createFile(filename); }
/*! * \brief Set the ramdisk address field in the boot image header * * \param bootImage CBootImage object * \param address Ramdisk address * * \sa BootImage::setRamdiskAddress() */ void mbp_bootimage_set_ramdisk_address(CBootImage *bootImage, uint32_t address) { CAST(bootImage); bi->setRamdiskAddress(address); }
void mbp_bootimage_set_apply_loki(CBootImage *bootImage, bool apply) { CAST(bootImage); bi->setApplyLoki(apply); }
/*! * \brief Set the second bootloader address field in the boot image header * * \param bootImage CBootImage object * \param address Second bootloader address * * \sa BootImage::setSecondBootloaderAddress() */ void mbp_bootimage_set_second_bootloader_address(CBootImage *bootImage, uint32_t address) { CAST(bootImage); bi->setSecondBootloaderAddress(address); }
void mbp_bootimage_set_apply_bump(CBootImage* bootImage, bool apply) { CAST(bootImage); bi->setApplyBump(apply); }
/*! * \brief Set the kernel tags address field in the boot image header * * \param bootImage CBootImage object * \param address Kernel tags address * * \sa BootImage::setKernelTagsAddress() */ void mbp_bootimage_set_kernel_tags_address(CBootImage *bootImage, uint32_t address) { CAST(bootImage); bi->setKernelTagsAddress(address); }
/*! * \brief Set the board name field in the boot image header * * \param bootImage CBootImage object * \param name Board name * * \sa BootImage::setBoardName() */ void mbp_bootimage_set_boardname(CBootImage *bootImage, const char *name) { CAST(bootImage); bi->setBoardName(name); }
/*! * \brief Set the kernel image * * \param bootImage CBootImage object * \param data Byte array containing kernel image * \param size Size of byte array * * \sa BootImage::setKernelImage() */ void mbp_bootimage_set_kernel_image(CBootImage *bootImage, const void *data, size_t size) { CAST(bootImage); bi->setKernelImage(data_to_vector(data, size)); }
/*! * \brief Resets the board name field in the boot image header to the default * * \param bootImage CBootImage object * * \sa BootImage::resetBoardName() */ void mbp_bootimage_reset_boardname(CBootImage *bootImage) { CAST(bootImage); bi->resetBoardName(); }
/*! * \brief Set the second bootloader image * * \param bootImage CBootImage object * \param data Byte array containing second bootloader image * \param size Size of byte array * * \sa BootImage::setSecondBootloaderImage() */ void mbp_bootimage_set_second_bootloader_image(CBootImage *bootImage, const void *data, size_t size) { CAST(bootImage); bi->setSecondBootloaderImage(data_to_vector(data, size)); }
/*! * \brief Set the kernel cmdline in the boot image header * * \param bootImage CBootImage object * \param cmdline Kernel cmdline * * \sa BootImage::setKernelCmdline() */ void mbp_bootimage_set_kernel_cmdline(CBootImage *bootImage, const char *cmdline) { CAST(bootImage); bi->setKernelCmdline(cmdline); }
/*! * \brief Set the device tree image * * \param bootImage CBootImage object * \param data Byte array containing device tree image * \param size Size of byte array * * \sa BootImage::setDeviceTreeImage() */ void mbp_bootimage_set_device_tree_image(CBootImage *bootImage, const void *data, size_t size) { CAST(bootImage); bi->setDeviceTreeImage(data_to_vector(data, size)); }
expression make_cast(location loc, asttype t, expression e) { expression result = CAST(expression, new_cast(parse_region, loc, e, t)); type castto = t->type; if (castto == error_type || type_void(castto)) ; /* Do nothing */ else if (type_array(castto)) { error("cast specifies array type"); castto = error_type; } else if (type_function(castto)) { error("cast specifies function type"); castto = error_type; } else if (type_equal_unqualified(castto, e->type)) { if (pedantic && type_aggregate(castto)) pedwarn("ANSI C forbids casting nonscalar to the same type"); } else { type etype = e->type; /* Convert functions and arrays to pointers, but don't convert any other types. */ if (type_function(etype) || type_array(etype)) etype = default_conversion(e); if (type_union(castto)) { tag_declaration utag = type_tag(castto); field_declaration ufield; /* Look for etype as a field of the union */ for (ufield = utag->fieldlist; ufield; ufield = ufield->next) if (ufield->name && type_equal_unqualified(ufield->type, etype)) { if (pedantic) pedwarn("ANSI C forbids casts to union type"); break; } if (!ufield) error("cast to union type from type not present in union"); } else { /* Optionally warn about potentially worrisome casts. */ if (warn_cast_qual && type_pointer(etype) && type_pointer(castto)) { type ep = type_points_to(etype), cp = type_points_to(castto); if (type_volatile(ep) && !type_volatile(cp)) pedwarn("cast discards `volatile' from pointer target type"); if (type_const(ep) && !type_const(cp)) pedwarn("cast discards `const' from pointer target type"); } /* This warning is weird */ if (warn_bad_function_cast && is_function_call(e) && !type_equal_unqualified(castto, etype)) warning ("cast does not match function type"); #if 0 /* Warn about possible alignment problems. */ if (STRICT_ALIGNMENT && warn_cast_align && TREE_CODE (type) == POINTER_TYPE && TREE_CODE (otype) == POINTER_TYPE && TREE_CODE (TREE_TYPE (otype)) != VOID_TYPE && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE /* Don't warn about opaque types, where the actual alignment restriction is unknown. */ && !((TREE_CODE (TREE_TYPE (otype)) == UNION_TYPE || TREE_CODE (TREE_TYPE (otype)) == RECORD_TYPE) && TYPE_MODE (TREE_TYPE (otype)) == VOIDmode) && TYPE_ALIGN (TREE_TYPE (type)) > TYPE_ALIGN (TREE_TYPE (otype))) warning ("cast increases required alignment of target type"); if (TREE_CODE (type) == INTEGER_TYPE && TREE_CODE (otype) == POINTER_TYPE && TYPE_PRECISION (type) != TYPE_PRECISION (otype) && !TREE_CONSTANT (value)) warning ("cast from pointer to integer of different size"); if (TREE_CODE (type) == POINTER_TYPE && TREE_CODE (otype) == INTEGER_TYPE && TYPE_PRECISION (type) != TYPE_PRECISION (otype) #if 0 /* Don't warn about converting 0 to pointer, provided the 0 was explicit--not cast or made by folding. */ && !(TREE_CODE (value) == INTEGER_CST && integer_zerop (value)) #endif /* Don't warn about converting any constant. */ && !TREE_CONSTANT (value)) warning ("cast to pointer from integer of different size"); #endif check_conversion(castto, etype); } } result->lvalue = !pedantic && e->lvalue; result->isregister = e->isregister; result->bitfield = e->bitfield; result->static_address = e->static_address; result->type = castto; result->cst = fold_cast(result); return result; }