Esempio n. 1
0
static int
osip_boot_helper( int sel, int *args )
{
	char *ustr, *s, *p, *buf;
	
	switch( args[0] ) {
	case kBootHAscii2Unicode: /* unicode_dest, src, maxlen -- uni_strlen */
		ustr = transl_mphys( args[1] );
		s = transl_mphys( args[2] );
		if( !ustr || !s )
			return -1;
		return asc2uni( (unsigned char *)ustr, s, args[3] );

	case kBootHUnicode2Ascii: /* dest, uni_str, uni_strlen, maxlen -- strlen */
		s = transl_mphys( args[1] );
		ustr = transl_mphys( args[2] );
		if( !ustr || !s )
			return -1;
		return uni2asc( s, (unsigned char *)ustr, args[3], args[4] );

	case kBootHGetStrResInd: /* resname, buf, len, index, argnum */
		p = transl_mphys( args[1] );
		buf = transl_mphys( args[2] );
		if( !p || !(s=get_str_res_ind(p,args[4],args[5])) )
			return 0;
		if( args[2] && buf )
			strncpy0( buf, s, args[3] );
		return args[2];

	case kBootHGetRAMSize:
		return ram.size;
	}
	return -1;
}
int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,
	     int saltlen, int id, int iter, int n, unsigned char *out,
	     const EVP_MD *md_type)
{
	int ret;
	unsigned char *unipass;
	int uniplen;
	if(!pass) {
		unipass = NULL;
		uniplen = 0;
	} else if (!asc2uni(pass, passlen, &unipass, &uniplen)) {
		PKCS12err(PKCS12_F_PKCS12_KEY_GEN_ASC,ERR_R_MALLOC_FAILURE);
		return 0;
	}
	ret = PKCS12_key_gen_uni(unipass, uniplen, salt, saltlen,
						 id, iter, n, out, md_type);
	if(unipass) {
		OPENSSL_cleanse(unipass, uniplen);	/* Clear password from memory */
		OPENSSL_free(unipass);
	}
	return ret;
}