import { __commonJS } from "../../../_virtual/rolldown_runtime.mjs";
import { require_forge } from "./forge.mjs";
import { require_util } from "./util.mjs";
import { require_oids } from "./oids.mjs";
import { require_asn1 } from "./asn1.mjs";
import { require_pem } from "./pem.mjs";
import { require_pbkdf2 } from "./pbkdf2.mjs";
import { require_rsa } from "./rsa.mjs";
import { require_pbe } from "./pbe.mjs";
import { require_pss } from "./pss.mjs";
import { require_x509 } from "./x509.mjs";
import { require_pkcs12 } from "./pkcs12.mjs";

//#region ../../node_modules/node-forge/lib/pki.js
var require_pki = /* @__PURE__ */ __commonJS({ "../../node_modules/node-forge/lib/pki.js": ((exports, module) => {
	/**
	* Javascript implementation of a basic Public Key Infrastructure, including
	* support for RSA public and private keys.
	*
	* @author Dave Longley
	*
	* Copyright (c) 2010-2013 Digital Bazaar, Inc.
	*/
	var forge = require_forge();
	require_asn1();
	require_oids();
	require_pbe();
	require_pem();
	require_pbkdf2();
	require_pkcs12();
	require_pss();
	require_rsa();
	require_util();
	require_x509();
	var asn1 = forge.asn1;
	var pki = module.exports = forge.pki = forge.pki || {};
	/**
	* NOTE: THIS METHOD IS DEPRECATED. Use pem.decode() instead.
	*
	* Converts PEM-formatted data to DER.
	*
	* @param pem the PEM-formatted data.
	*
	* @return the DER-formatted data.
	*/
	pki.pemToDer = function(pem) {
		var msg = forge.pem.decode(pem)[0];
		if (msg.procType && msg.procType.type === "ENCRYPTED") throw new Error("Could not convert PEM to DER; PEM is encrypted.");
		return forge.util.createBuffer(msg.body);
	};
	/**
	* Converts an RSA private key from PEM format.
	*
	* @param pem the PEM-formatted private key.
	*
	* @return the private key.
	*/
	pki.privateKeyFromPem = function(pem) {
		var msg = forge.pem.decode(pem)[0];
		if (msg.type !== "PRIVATE KEY" && msg.type !== "RSA PRIVATE KEY") {
			var error = /* @__PURE__ */ new Error("Could not convert private key from PEM; PEM header type is not \"PRIVATE KEY\" or \"RSA PRIVATE KEY\".");
			error.headerType = msg.type;
			throw error;
		}
		if (msg.procType && msg.procType.type === "ENCRYPTED") throw new Error("Could not convert private key from PEM; PEM is encrypted.");
		var obj = asn1.fromDer(msg.body);
		return pki.privateKeyFromAsn1(obj);
	};
	/**
	* Converts an RSA private key to PEM format.
	*
	* @param key the private key.
	* @param maxline the maximum characters per line, defaults to 64.
	*
	* @return the PEM-formatted private key.
	*/
	pki.privateKeyToPem = function(key, maxline) {
		var msg = {
			type: "RSA PRIVATE KEY",
			body: asn1.toDer(pki.privateKeyToAsn1(key)).getBytes()
		};
		return forge.pem.encode(msg, { maxline });
	};
	/**
	* Converts a PrivateKeyInfo to PEM format.
	*
	* @param pki the PrivateKeyInfo.
	* @param maxline the maximum characters per line, defaults to 64.
	*
	* @return the PEM-formatted private key.
	*/
	pki.privateKeyInfoToPem = function(pki$1, maxline) {
		var msg = {
			type: "PRIVATE KEY",
			body: asn1.toDer(pki$1).getBytes()
		};
		return forge.pem.encode(msg, { maxline });
	};
}) });

//#endregion
export default require_pki();

export { require_pki };
//# sourceMappingURL=pki.mjs.map