Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
fix(pki): support RSA-OAEP key transport in SCEP so Windows Intune devices can enroll
Carlos Monastyrski9e1a9c2d3036
diff --git a/backend/src/ee/services/pki-scep/pki-scep-crypto.ts b/backend/src/ee/services/pki-scep/pki-scep-crypto.tsindex babd12847a..7a5c3bc3e8 100644--- a/backend/src/ee/services/pki-scep/pki-scep-crypto.ts+++ b/backend/src/ee/services/pki-scep/pki-scep-crypto.ts@@ -4,7 +4,7 @@ import { BadRequestError } from "@app/lib/errors";import { CIPHER_OID_MAP, DIGEST_OID_TO_HASH } from "./pki-scep-types";-export { rsaPkcs1Decrypt, rsaPkcs1Encrypt, rsaSign } from "@app/lib/crypto/rsa";+export { rsaOaepDecrypt, rsaPkcs1Decrypt, rsaPkcs1Encrypt, rsaSign } from "@app/lib/crypto/rsa";const { nativeCrypto, randomBytes } = crypto;diff --git a/backend/src/ee/services/pki-scep/pki-scep-message-builder.ts b/backend/src/ee/services/pki-scep/pki-scep-message-builder.tsindex 948e1cd13f..03b2274e88 100644--- a/backend/src/ee/services/pki-scep/pki-scep-message-builder.ts+++ b/backend/src/ee/services/pki-scep/pki-scep-message-builder.ts@@ -15,7 +15,7 @@ import { crypto } from "@app/lib/crypto/cryptography";import { buildResponseAttributes } from "./pki-scep-attributes";import { rsaPkcs1Encrypt, rsaSign, symmetricEncryptWithOid } from "./pki-scep-crypto";-import { ScepFailInfo, ScepPkiStatus } from "./pki-scep-types";+import { KEY_TRANSPORT_OIDS, ScepFailInfo, ScepPkiStatus } from "./pki-scep-types";export const buildCertRepSuccess = ({issuedCertDer,@@ -246,7 +246,7 @@ const buildEnvelopedDataDer = (}).toSchema(),// keyEncryptionAlgorithmnew AlgorithmIdentifier({- algorithmId: "1.2.840.113549.1.1.1" // rsaEncryption+ algorithmId: KEY_TRANSPORT_OIDS.rsaEncryption}).toSchema(),// encryptedKeynew asn1js.OctetString({ valueHex: encryptedCek })diff --git a/backend/src/ee/services/pki-scep/pki-scep-message-parser.test.ts b/backend/src/ee/services/pki-scep/pki-scep-message-parser.test.tsnew file mode 100644index 0000000000..f5b2431244--- /dev/null+++ b/backend/src/ee/services/pki-scep/pki-scep-message-parser.test.ts@@ -0,0 +1,293 @@+import crypto from "node:crypto";++import * as x509 from "@peculiar/x509";+import * as asn1js from "asn1js";+import {+ AlgorithmIdentifier,+ Attribute,+ Certificate,+ ContentInfo,+ EncapsulatedContentInfo,+ IssuerAndSerialNumber,+ RSAESOAEPParams,+ SignedAndUnsignedAttributes,+ SignedData,+ SignerInfo+} from "pkijs";+import { beforeAll, describe, expect, test } from "vitest";++import { parseScepMessage } from "./pki-scep-message-parser";+import { KEY_TRANSPORT_OIDS, SCEP_OIDS, ScepMessageType } from "./pki-scep-types";++const AES_128_CBC_OID = "2.16.840.1.101.3.4.1.2";+const SHA1_OID = "1.3.14.3.2.26";+const SHA256_OID = "2.16.840.1.101.3.4.2.1";++type TIdentity = { certificate: Certificate; privateKey: crypto.KeyObject; publicKey: crypto.KeyObject };++type TKeyEncryption = {+ algorithm: AlgorithmIdentifier;+ wrap: (cek: Buffer, recipientPublicKey: crypto.KeyObject) => Buffer;+};++const oaepParams = (hashOid: string, mgfHashOid: string, pSourceAlgorithm?: AlgorithmIdentifier) =>+ new RSAESOAEPParams({+ hashAlgorithm: new AlgorithmIdentifier({ algorithmId: hashOid }),+ maskGenAlgorithm: new AlgorithmIdentifier({+ algorithmId: KEY_TRANSPORT_OIDS.mgf1,+ algorithmParams: new AlgorithmIdentifier({ algorithmId: mgfHashOid }).toSchema()+ }),+ ...(pSourceAlgorithm && { pSourceAlgorithm })+ }).toSchema();++const OAEP_LABEL = Buffer.from("scep-oaep-label");++const PKCS1_V15: TKeyEncryption = {+ algorithm: new AlgorithmIdentifier({+ algorithmId: KEY_TRANSPORT_OIDS.rsaEncryption,+ algorithmParams: new asn1js.Null()+ }),+ wrap: (cek, key) => crypto.publicEncrypt({ key, padding: crypto.constants.RSA_PKCS1_PADDING }, cek)+};++const OAEP_DEFAULT_PARAMS: TKeyEncryption = {+ algorithm: new AlgorithmIdentifier({+ algorithmId: KEY_TRANSPORT_OIDS.rsaesOaep,+ algorithmParams: new asn1js.Sequence()+ }),+ wrap: (cek, key) =>+ crypto.publicEncrypt({ key, padding: crypto.constants.RSA_PKCS1_OAEP_PADDING, oaepHash: "sha1" }, cek)+};++const OAEP_SHA256: TKeyEncryption = {+ algorithm: new AlgorithmIdentifier({+ algorithmId: KEY_TRANSPORT_OIDS.rsaesOaep,+ algorithmParams: oaepParams(SHA256_OID, SHA256_OID)+ }),+ wrap: (cek, key) =>+ crypto.publicEncrypt({ key, padding: crypto.constants.RSA_PKCS1_OAEP_PADDING, oaepHash: "sha256" }, cek)+};++const OAEP_SHA256_WITH_LABEL: TKeyEncryption = {+ algorithm: new AlgorithmIdentifier({+ algorithmId: KEY_TRANSPORT_OIDS.rsaesOaep,+ algorithmParams: oaepParams(+ SHA256_OID,+ SHA256_OID,+ new AlgorithmIdentifier({+ algorithmId: KEY_TRANSPORT_OIDS.pSpecified,+ algorithmParams: new asn1js.OctetString({ valueHex: OAEP_LABEL })+ })+ )+ }),+ wrap: (cek, key) =>+ crypto.publicEncrypt(+ { key, padding: crypto.constants.RSA_PKCS1_OAEP_PADDING, oaepHash: "sha256", oaepLabel: OAEP_LABEL },+ cek+ )+};++const createIdentity = async (commonName: string): Promise<TIdentity> => {+ const keys = await globalThis.crypto.subtle.generateKey(+ { name: "RSASSA-PKCS1-v1_5", modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]), hash: "SHA-256" },+ true,+ ["sign", "verify"]+ );+ const cert = await x509.X509CertificateGenerator.createSelfSigned({+ serialNumber: crypto.randomBytes(8).toString("hex"),+ name: `CN=${commonName}`,+ notBefore: new Date(),+ notAfter: new Date(Date.now() + 24 * 60 * 60 * 1000),+ signingAlgorithm: { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" },+ keys+ });+ const privateKeyDer = Buffer.from(await globalThis.crypto.subtle.exportKey("pkcs8", keys.privateKey));++ return {+ certificate: new Certificate({ schema: asn1js.fromBER(cert.rawData).result }),+ privateKey: crypto.createPrivateKey({ key: privateKeyDer, format: "der", type: "pkcs8" }),+ publicKey: crypto.createPublicKey({ key: Buffer.from(cert.publicKey.rawData), format: "der", type: "spki" })+ };+};++const buildEnvelopedData = (plainText: Buffer, recipient: TIdentity, keyEncryption: TKeyEncryption): Buffer => {+ const cek = crypto.randomBytes(16);+ const iv = crypto.randomBytes(16);+ const cipher = crypto.createCipheriv("aes-128-cbc", cek, iv);+ const encryptedContent = Buffer.concat([cipher.update(plainText), cipher.final()]);++ const keyTransRecipientInfo = new asn1js.Sequence({+ value: [+ new asn1js.Integer({ value: 0 }),+ new IssuerAndSerialNumber({+ issuer: recipient.certificate.issuer,+ serialNumber: recipient.certificate.serialNumber+ }).toSchema(),+ keyEncryption.algorithm.toSchema(),+ new asn1js.OctetString({ valueHex: keyEncryption.wrap(cek, recipient.publicKey) })+ ]+ });++ const envelopedData = new asn1js.Sequence({+ value: [+ new asn1js.Integer({ value: 0 }),+ new asn1js.Set({ value: [keyTransRecipientInfo] }),+ new asn1js.Sequence({+ value: [+ new asn1js.ObjectIdentifier({ value: "1.2.840.113549.1.7.1" }),+ new AlgorithmIdentifier({+ algorithmId: AES_128_CBC_OID,+ algorithmParams: new asn1js.OctetString({ valueHex: iv })+ }).toSchema(),+ new asn1js.Primitive({ idBlock: { tagClass: 3, tagNumber: 0 }, valueHex: encryptedContent })+ ]+ })+ ]+ });++ return Buffer.from(+ new ContentInfo({ contentType: "1.2.840.113549.1.7.3", content: envelopedData }).toSchema().toBER(false)+ );+};++const buildPkcsReq = (plainText: Buffer, client: TIdentity, ra: TIdentity, keyEncryption: TKeyEncryption) => {+ const envelopedDataDer = buildEnvelopedData(plainText, ra, keyEncryption);++ const signedAttrs = new SignedAndUnsignedAttributes({+ type: 0,+ attributes: [+ new Attribute({+ type: "1.2.840.113549.1.9.3",+ values: [new asn1js.ObjectIdentifier({ value: "1.2.840.113549.1.7.1" })]+ }),+ new Attribute({+ type: "1.2.840.113549.1.9.4",+ values: [new asn1js.OctetString({ valueHex: crypto.createHash("sha256").update(envelopedDataDer).digest() })]+ }),+ new Attribute({+ type: SCEP_OIDS.messageType,+ values: [new asn1js.PrintableString({ value: ScepMessageType.PKCSReq })]+ }),+ new Attribute({+ type: SCEP_OIDS.transactionId,+ values: [new asn1js.PrintableString({ value: "test-transaction" })]+ }),+ new Attribute({+ type: SCEP_OIDS.senderNonce,+ values: [new asn1js.OctetString({ valueHex: crypto.randomBytes(16) })]+ })+ ]+ });++ const signedAttrsDer = Buffer.from(signedAttrs.toSchema().toBER(false));+ signedAttrsDer[0] = 0x31;++ const signedData = new SignedData({+ version: 1,+ digestAlgorithms: [new AlgorithmIdentifier({ algorithmId: SHA256_OID })],+ encapContentInfo: new EncapsulatedContentInfo({+ eContentType: "1.2.840.113549.1.7.1",+ eContent: new asn1js.OctetString({ valueHex: envelopedDataDer })+ }),+ certificates: [client.certificate],+ signerInfos: [+ new SignerInfo({+ version: 1,+ sid: new IssuerAndSerialNumber({+ issuer: client.certificate.issuer,+ serialNumber: client.certificate.serialNumber+ }),+ digestAlgorithm: new AlgorithmIdentifier({ algorithmId: SHA256_OID }),+ signedAttrs,+ signatureAlgorithm: new AlgorithmIdentifier({ algorithmId: "1.2.840.113549.1.1.11" }),+ signature: new asn1js.OctetString({ valueHex: crypto.sign("sha256", signedAttrsDer, client.privateKey) })+ })+ ]+ });++ return Buffer.from(+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment+ new ContentInfo({ contentType: "1.2.840.113549.1.7.2", content: signedData.toSchema() }).toSchema().toBER(false)+ );+};++const exportPkcs8 = (identity: TIdentity) => identity.privateKey.export({ format: "der", type: "pkcs8" });++describe("parseScepMessage key transport", () => {+ let ra: TIdentity;+ let client: TIdentity;+ const csr = Buffer.from("certificate request bytes");++ beforeAll(async () => {+ x509.cryptoProvider.set(globalThis.crypto);+ ra = await createIdentity("Infisical SCEP RA");+ client = await createIdentity("SCEP Protocol Certificate");+ });++ test.each([+ ["RSA PKCS#1 v1.5", PKCS1_V15],+ ["RSAES-OAEP with default SHA-1 parameters", OAEP_DEFAULT_PARAMS],+ ["RSAES-OAEP with SHA-256 parameters", OAEP_SHA256],+ ["RSAES-OAEP with an explicit label", OAEP_SHA256_WITH_LABEL]+ ])("decrypts a PKCSReq whose content key is wrapped with %s", (_name, keyEncryption) => {+ const parsed = parseScepMessage(buildPkcsReq(csr, client, ra, keyEncryption), exportPkcs8(ra));++ expect(parsed.messageType).toBe(ScepMessageType.PKCSReq);+ expect(parsed.csr?.equals(csr)).toBe(true);+ expect(parsed.clientCipherOid).toBe(AES_128_CBC_OID);+ });++ test("rejects RSAES-OAEP whose mask generation hash differs from its digest", () => {+ const mismatched: TKeyEncryption = {+ algorithm: new AlgorithmIdentifier({+ algorithmId: KEY_TRANSPORT_OIDS.rsaesOaep,+ algorithmParams: oaepParams(SHA256_OID, SHA1_OID)+ }),+ wrap: OAEP_SHA256.wrap+ };++ expect(() => parseScepMessage(buildPkcsReq(csr, client, ra, mismatched), exportPkcs8(ra))).toThrow(+ "RSA-OAEP with unsupported parameters"+ );+ });++ test("rejects RSAES-OAEP parameters that do not match the RSAES-OAEP-params structure", () => {+ const malformed: TKeyEncryption = {+ algorithm: new AlgorithmIdentifier({+ algorithmId: KEY_TRANSPORT_OIDS.rsaesOaep,+ algorithmParams: new asn1js.Sequence({ value: [new asn1js.Integer({ value: 5 })] })+ }),+ wrap: OAEP_DEFAULT_PARAMS.wrap+ };++ expect(() => parseScepMessage(buildPkcsReq(csr, client, ra, malformed), exportPkcs8(ra))).toThrow(+ "malformed RSA-OAEP parameters"+ );+ });++ test("rejects an RSAES-OAEP label source other than pSpecified", () => {+ const unsupportedLabelSource: TKeyEncryption = {+ algorithm: new AlgorithmIdentifier({+ algorithmId: KEY_TRANSPORT_OIDS.rsaesOaep,+ algorithmParams: oaepParams(+ SHA256_OID,+ SHA256_OID,+ new AlgorithmIdentifier({ algorithmId: SHA1_OID, algorithmParams: new asn1js.OctetString() })+ )+ }),+ wrap: OAEP_SHA256.wrap+ };++ expect(() => parseScepMessage(buildPkcsReq(csr, client, ra, unsupportedLabelSource), exportPkcs8(ra))).toThrow(+ "unsupported RSA-OAEP label source"+ );+ });++ test("rejects a PKCSReq encrypted for a different key", async () => {+ const otherRa = await createIdentity("Other RA");++ expect(() => parseScepMessage(buildPkcsReq(csr, client, otherRa, OAEP_DEFAULT_PARAMS), exportPkcs8(ra))).toThrow(+ "Failed to decrypt SCEP enveloped data"+ );+ });+});diff --git a/backend/src/ee/services/pki-scep/pki-scep-message-parser.ts b/backend/src/ee/services/pki-scep/pki-scep-message-parser.tsindex f1287b7e06..46ef188d97 100644--- a/backend/src/ee/services/pki-scep/pki-scep-message-parser.ts+++ b/backend/src/ee/services/pki-scep/pki-scep-message-parser.ts@@ -1,12 +1,26 @@import * as asn1js from "asn1js";-import { Certificate, type CertificateSetItem, ContentInfo, SignedData, type SignerInfo as PkiSignerInfo } from "pkijs";+import {+ AlgorithmIdentifier,+ Certificate,+ type CertificateSetItem,+ ContentInfo,+ RSAESOAEPParams,+ SignedData,+ type SignerInfo as PkiSignerInfo+} from "pkijs";import { crypto } from "@app/lib/crypto/cryptography";import { BadRequestError } from "@app/lib/errors";import { extractScepAttributes } from "./pki-scep-attributes";-import { rsaPkcs1Decrypt, rsaVerify, symmetricDecrypt } from "./pki-scep-crypto";-import { CIPHER_OID_MAP, DIGEST_OID_TO_HASH, ScepMessageType, TParsedScepMessage } from "./pki-scep-types";+import { rsaOaepDecrypt, rsaPkcs1Decrypt, rsaVerify, symmetricDecrypt } from "./pki-scep-crypto";+import {+ CIPHER_OID_MAP,+ DIGEST_OID_TO_HASH,+ KEY_TRANSPORT_OIDS,+ ScepMessageType,+ TParsedScepMessage+} from "./pki-scep-types";export const parseScepMessage = (derMessage: Buffer, raPrivateKeyDer: Buffer): TParsedScepMessage => {// Parse the outer ContentInfo@@ -252,6 +266,88 @@ const extractRawBytes = (element: asn1js.BaseBlock): Buffer => {return extractTlvValueBytes(fullDer);};+enum KeyTransportScheme {+ RsaPkcs1 = "rsa-pkcs1",+ RsaOaep = "rsa-oaep"+}++type TKeyTransport =+ | { scheme: KeyTransportScheme.RsaPkcs1 }+ | { scheme: KeyTransportScheme.RsaOaep; hash: string; label?: Buffer };++const OAEP_P_SOURCE_TAG_NUMBER = 2;++const parseOaepParams = (oaepParamsSchema?: asn1js.Sequence) => {+ try {+ const oaepParams = oaepParamsSchema ? new RSAESOAEPParams({ schema: oaepParamsSchema }) : new RSAESOAEPParams();+ const mgfParams: unknown = oaepParams.maskGenAlgorithm.algorithmParams;+ const mgfHashOid =+ oaepParams.maskGenAlgorithm.algorithmId === KEY_TRANSPORT_OIDS.mgf1 && mgfParams instanceof asn1js.Sequence+ ? new AlgorithmIdentifier({ schema: mgfParams }).algorithmId+ : undefined;+ return { oaepParams, mgfHashOid };+ } catch {+ throw new BadRequestError({+ message: "The SCEP client sent malformed RSA-OAEP parameters, so its request could not be decrypted."+ });+ }+};++const parseKeyTransportAlgorithm = (keyEncryptionAlgorithm: asn1js.BaseBlock): TKeyTransport => {+ let algorithm: AlgorithmIdentifier;+ try {+ algorithm = new AlgorithmIdentifier({ schema: keyEncryptionAlgorithm });+ } catch {+ throw new BadRequestError({+ message: "The SCEP client sent a malformed key encryption algorithm, so its request could not be decrypted."+ });+ }++ if (algorithm.algorithmId === KEY_TRANSPORT_OIDS.rsaEncryption) {+ return { scheme: KeyTransportScheme.RsaPkcs1 };+ }++ if (algorithm.algorithmId !== KEY_TRANSPORT_OIDS.rsaesOaep) {+ throw new BadRequestError({+ message: `The SCEP client encrypted its request with an unsupported key encryption algorithm (OID ${algorithm.algorithmId}). Supported algorithms are RSA PKCS#1 v1.5 and RSA-OAEP.`+ });+ }++ const { algorithmParams } = algorithm as { algorithmParams: unknown };+ const oaepParamsSchema = algorithmParams instanceof asn1js.Sequence ? algorithmParams : undefined;+ const { oaepParams, mgfHashOid } = parseOaepParams(oaepParamsSchema);++ const hashOid = oaepParams.hashAlgorithm.algorithmId;+ const hash = DIGEST_OID_TO_HASH[hashOid];+ if (!hash || mgfHashOid !== hashOid) {+ throw new BadRequestError({+ message: `The SCEP client used RSA-OAEP with unsupported parameters (hash OID ${hashOid}, mask generation OID ${+ mgfHashOid ?? oaepParams.maskGenAlgorithm.algorithmId+ }). RSA-OAEP is supported with SHA-1, SHA-256, SHA-384, or SHA-512 and MGF1 using the same hash.`+ });+ }++ const hasExplicitPSource =+ oaepParamsSchema?.valueBlock.value.some(+ (paramElement) =>+ paramElement.idBlock.tagClass === 3 && paramElement.idBlock.tagNumber === OAEP_P_SOURCE_TAG_NUMBER+ ) ?? false;+ if (!hasExplicitPSource) {+ return { scheme: KeyTransportScheme.RsaOaep, hash };+ }++ const { pSourceAlgorithm } = oaepParams;+ const label: unknown = pSourceAlgorithm.algorithmParams;+ if (pSourceAlgorithm.algorithmId !== KEY_TRANSPORT_OIDS.pSpecified || !(label instanceof asn1js.OctetString)) {+ throw new BadRequestError({+ message: `The SCEP client used an unsupported RSA-OAEP label source (OID ${pSourceAlgorithm.algorithmId}). Only an explicit label (pSpecified) is supported.`+ });+ }++ const labelBytes = Buffer.from(label.valueBlock.valueHexView);+ return { scheme: KeyTransportScheme.RsaOaep, hash, label: labelBytes.length ? labelBytes : undefined };+};+const decryptEnvelopedDataRaw = (envelopedDataDer: Buffer,raPrivateKeyDer: Buffer@@ -351,10 +447,15 @@ const decryptEnvelopedDataRaw = (throw new BadRequestError({ message: "Failed to extract encrypted content from EncryptedContentInfo" });}+ const keyTransport = parseKeyTransportAlgorithm(ktri[ktri.length - 2]);+// Decrypt the contentlet contentEncryptionKey: Buffer;try {- const decrypted = rsaPkcs1Decrypt(encryptedKey, raPrivateKeyDer);+ const decrypted =+ keyTransport.scheme === KeyTransportScheme.RsaOaep+ ? rsaOaepDecrypt(encryptedKey, raPrivateKeyDer, keyTransport)+ : rsaPkcs1Decrypt(encryptedKey, raPrivateKeyDer);contentEncryptionKey =decrypted.length === cipherInfo.keyLength ? decrypted : crypto.randomBytes(cipherInfo.keyLength);} catch {diff --git a/backend/src/ee/services/pki-scep/pki-scep-types.ts b/backend/src/ee/services/pki-scep/pki-scep-types.tsindex a378626d14..a3d26eca9c 100644--- a/backend/src/ee/services/pki-scep/pki-scep-types.ts+++ b/backend/src/ee/services/pki-scep/pki-scep-types.ts@@ -47,6 +47,13 @@ export const SCEP_OIDS = {recipientNonce: "2.16.840.1.113733.1.9.6"} as const;+export const KEY_TRANSPORT_OIDS = {+ rsaEncryption: "1.2.840.113549.1.1.1",+ rsaesOaep: "1.2.840.113549.1.1.7",+ mgf1: "1.2.840.113549.1.1.8",+ pSpecified: "1.2.840.113549.1.1.9"+} as const;+export const DIGEST_OID_TO_HASH: Record<string, string> = {"2.16.840.1.101.3.4.2.1": "sha256","1.3.14.3.2.26": "sha1",diff --git a/backend/src/lib/crypto/cryptography/crypto.ts b/backend/src/lib/crypto/cryptography/crypto.tsindex f2913de7c2..badd8b420d 100644--- a/backend/src/lib/crypto/cryptography/crypto.ts+++ b/backend/src/lib/crypto/cryptography/crypto.ts@@ -479,6 +479,7 @@ const cryptographyFactory = () => {createDecipheriv: crypto.createDecipheriv,createPublicKey: crypto.createPublicKey,createPrivateKey: crypto.createPrivateKey,+ privateDecrypt: crypto.privateDecrypt,getRandomValues: crypto.getRandomValues,randomUUID: crypto.randomUUID,// The same object as node:crypto's webcrypto.subtle, but DOM-typed: @peculiar/x509 expects DOMdiff --git a/backend/src/lib/crypto/index.ts b/backend/src/lib/crypto/index.tsindex 04360000db..8660c5e862 100644--- a/backend/src/lib/crypto/index.ts+++ b/backend/src/lib/crypto/index.ts@@ -6,7 +6,7 @@ export {} from "./blind-index";export { crypto, SymmetricKeySize } from "./cryptography";export { buildSecretBlindIndexFromName } from "./encryption";-export { rsaPkcs1Decrypt, rsaPkcs1Encrypt, rsaSign, rsaVerify } from "./rsa";+export { rsaOaepDecrypt, rsaPkcs1Decrypt, rsaPkcs1Encrypt, rsaSign, rsaVerify } from "./rsa";export {decryptIntegrationAuths,decryptSecretApprovals,diff --git a/backend/src/lib/crypto/rsa.ts b/backend/src/lib/crypto/rsa.tsindex 2e4d7e6526..a0d6e56704 100644--- a/backend/src/lib/crypto/rsa.ts+++ b/backend/src/lib/crypto/rsa.ts@@ -21,6 +21,21 @@ export const rsaPkcs1Decrypt = (encryptedKey: Buffer, privateKeyDer: Buffer): Bureturn Buffer.from(decrypted, "binary");};+export const rsaOaepDecrypt = (+ encryptedKey: Buffer,+ privateKeyDer: Buffer,+ { hash, label }: { hash: string; label?: Buffer }+): Buffer =>+ nativeCrypto.privateDecrypt(+ {+ key: nativeCrypto.createPrivateKey({ key: privateKeyDer, format: "der", type: "pkcs8" }),+ padding: nativeCrypto.constants.RSA_PKCS1_OAEP_PADDING,+ oaepHash: hash,+ oaepLabel: label+ },+ encryptedKey+ );+/*** RSA PKCS#1 v1.5 encryption using node-forge.* Counterpart to rsaPkcs1Decrypt — uses forge for consistency.diff --git a/docs/documentation/platform/pki/guides/applications/microsoft-intune-scep.mdx b/docs/documentation/platform/pki/guides/applications/microsoft-intune-scep.mdxindex 8e238ed2b1..1417437590 100644--- a/docs/documentation/platform/pki/guides/applications/microsoft-intune-scep.mdx+++ b/docs/documentation/platform/pki/guides/applications/microsoft-intune-scep.mdx@@ -264,10 +264,14 @@ This profile gives each device the address of your endpoint and a single-use cha| **Root Certificate** | The trusted certificate profile you just created || **Extended key usage** | **Client Authentication**, matching the certificate profile || **Renewal threshold (%)** | 20 |- | **SCEP Server URLs** | The **SCEP endpoint URL** you copied from Infisical |+ | **SCEP Server URLs** | The **SCEP endpoint URL** you copied from Infisical (remove `/pkiclient.exe` on Windows) |+ <Warning>+ On Windows, remove `/pkiclient.exe` from the end of the URL. Windows adds `/pkiclient.exe` to the URL itself, so if you leave it in, the device requests `.../pkiclient.exe/pkiclient.exe` and never enrolls. On Apple platforms, keep the full URL.+ </Warning>+**Certificate validity period** and **Extended key usage** are the two you're mirroring from [Step 1](#step-1-prepare-the-certificate-profile-in-infisical). Intune reports the enrollment as successful without comparing either one against the certificate it receives, so a mismatch here is never flagged.<Note>