static void enable_paging(void) { // turn on paging //uint32_t cr0 = rcr0(); //cr0 |= CR0_PE | CR0_PG | CR0_AM | CR0_WP | CR0_NE | CR0_TS | CR0_EM | CR0_MP; //cr0 &= ~(CR0_TS | CR0_EM); clis(); lcr0(); lcr3(boot_cr3); M2S(); stis(); }
/** Send status lines in the format S KEYPAIRINFO <hexstring_with_keygrip> <hexstring_with_id> S CERTINFO <certtype> <hexstring_with_id> If certificate is issuer, we set type to 102 (useful); otherwise it is assumed that we're in posession of private key, so the type is set to 101 (trusted). The certificate ID is percent-plus escaped displayName. */ static int send_certificate_list ( assuan_context_t ctx, pkcs11h_certificate_id_list_t head, /* list head */ int is_issuer /* true if issuer certificate */ ) { cmd_data_t *data = (cmd_data_t *)assuan_get_pointer (ctx); gpg_err_code_t error = GPG_ERR_GENERAL; pkcs11h_certificate_id_list_t curr_cert; for ( curr_cert = head; curr_cert != NULL; curr_cert = curr_cert->next ) { char *certid = NULL; char *key_hexgrip = NULL; char *keypairinfo = NULL; char *gpginfo = NULL; char *info_cert = NULL; gcry_sexp_t sexp = NULL; size_t ser_len; char *key_prefix = NULL; char *nameinfo = NULL; if ((error = get_cert_sexp (ctx, curr_cert->certificate_id, &sexp)) != GPG_ERR_NO_ERROR) { goto retry; } if ((key_hexgrip = keyutil_get_cert_hexgrip (sexp)) == NULL) { error = GPG_ERR_ENOMEM; goto retry; } if ( (error = common_map_pkcs11_error ( pkcs11h_certificate_serializeCertificateId ( NULL, &ser_len, curr_cert->certificate_id ) )) != GPG_ERR_NO_ERROR ) { goto retry; } if ((certid = (char *)malloc (ser_len)) == NULL ) { error = GPG_ERR_ENOMEM; goto retry; } if ( (error = common_map_pkcs11_error ( pkcs11h_certificate_serializeCertificateId ( certid, &ser_len, curr_cert->certificate_id ) )) != GPG_ERR_NO_ERROR ) { goto retry; } if ((info_cert = strdup (is_issuer ? "102 " : "101 ")) == NULL) { error = GPG_ERR_ENOMEM; goto retry; } if (!encoding_strappend (&info_cert, certid)) { error = GPG_ERR_ENOMEM; goto retry; } if ( data->config->openpgp_sign != NULL && !strcmp (data->config->openpgp_sign, key_hexgrip) ) { key_prefix = M2S(OPENPGP_SIGN) " "; } else if ( data->config->openpgp_encr != NULL && !strcmp (data->config->openpgp_encr, key_hexgrip) ) { key_prefix = M2S(OPENPGP_ENCR) " "; } else if ( data->config->openpgp_auth != NULL && !strcmp (data->config->openpgp_auth, key_hexgrip) ) { key_prefix = M2S(OPENPGP_AUTH) " "; } if ( (nameinfo = strdup (key_hexgrip)) == NULL || !encoding_strappend (&nameinfo, " ") || !encoding_strappend (&nameinfo, curr_cert->certificate_id->displayName) ) { error = GPG_ERR_ENOMEM; goto retry; } if ( (error = assuan_write_status ( ctx, "KEY-FRIEDNLY", nameinfo )) != GPG_ERR_NO_ERROR ) { goto retry; } if (key_prefix != NULL) { if ( (gpginfo = strdup (key_prefix)) == NULL || !encoding_strappend (&gpginfo, key_hexgrip) ) { error = GPG_ERR_ENOMEM; goto retry; } if ( (error = assuan_write_status ( ctx, "KEY-FPR", gpginfo )) != GPG_ERR_NO_ERROR ) { goto retry; } } if ( (error = assuan_write_status ( ctx, "CERTINFO", info_cert )) != GPG_ERR_NO_ERROR ) { goto retry; } /* send keypairinfo if not issuer certificate */ if(!is_issuer) { if ( (keypairinfo = strdup (key_hexgrip)) == NULL || !encoding_strappend (&keypairinfo, " ") || !encoding_strappend (&keypairinfo, certid) ) { error = GPG_ERR_ENOMEM; goto retry; } if ( (error = assuan_write_status ( ctx, "KEYPAIRINFO", keypairinfo )) != GPG_ERR_NO_ERROR ) { goto retry; } } error = GPG_ERR_NO_ERROR; retry: if (info_cert != NULL) { free (info_cert); info_cert = NULL; } if (certid != NULL) { free (certid); certid = NULL; } if (key_hexgrip != NULL) { free (key_hexgrip); key_hexgrip = NULL; } if (keypairinfo != NULL) { free (keypairinfo); keypairinfo = NULL; } if (gpginfo != NULL) { free (gpginfo); gpginfo = NULL; } if (nameinfo != NULL) { free (nameinfo); nameinfo = NULL; } if (error != GPG_ERR_NO_ERROR) { goto cleanup; } } error = GPG_ERR_NO_ERROR; cleanup: return error; }