1

我正在编写一个 JS 脚本(将应用程序上传到 intune 的 ru。当我尝试将应用程序内容文件提交到 intune 时,我总是收到 commitFileFailed,我看不出有任何原因。有什么办法可以弄清楚为什么会失败?

我认为这可能是因为加密,但我不太确定。这就是我加密它的方式:

const key = Crypto.randomBytes(32);
const hmacKey = Crypto.randomBytes(32);
const iv = Crypto.randomBytes(16);
const cipher = Crypto.createCipheriv('aes256', key, iv);
const hmac = Crypto.createHmac('sha256', hmacKey);
const hash = Crypto.createHash('sha256');

let encrypted = cipher.update(originalFileBuffer);
encrypted = [...encrypted, ...cipher.final()];
const encryptedBuffer = Buffer.from(encrypted);

let encryptedHmac = hmac.update(encryptedBuffer);
let digest = hmac.digest('base64');

hash.update(Buffer.from(originalFileBuffer));
const fileDigest = hash.digest('base64');

const encryptionInfo = {
    fileEncryptionInfo: {
        '@odata.type': 'microsoft.graph.fileEncryptionInfo',
        encryptionKey: Buffer.from(key).toString('base64'),
        macKey: Buffer.from(hmacKey).toString('base64'),
        initializationVector: Buffer.from(iv).toString('base64'),
        mac: digest,
        profileIdentifier: 'ProfileVersion1',
        fileDigest: fileDigest,
        fileDigestAlgorithm: 'SHA256'
    }
};

我的加密信息如下所示:

{
  "encryptionKey": "5hYywG3rkdeMLSuvW6xyvA==",
  "macKey": "0PVu0l0avph6p2E3HCpHIw==",
  "initializationVector": "UQVtvxe4n28oWrMLz5ei9w==",
  "mac": "hjD5yZnOPFJjgijB4vtdw+6Lh8U3X2Xnp8dOcscv/QI=",
  "profileIdentifier": "ProfileVersion1",
  "fileDigest": "wMlT8MU7Rm0BXzIj8STRCjjye/Hn0UQTqQ9A2eRb41U=",
  "fileDigestAlgorithm": "SHA256"
}

像这样的清单:

<?xml version="1.0" encoding="utf-8"?>
<AndroidManifestProperties xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Package>test.android.app</Package>
    <PackageVersionCode>1</PackageVersionCode>
    <PackageVersionName>1.0.0</PackageVersionName>
    <ApplicationName>TestApp.apk</ApplicationName>
    <MinSdkVersion>4</MinSdkVersion>
    <AWTVersion/>
</AndroidManifestProperties>

任何帮助,将不胜感激。谢谢。

4

0 回答 0