@semi-app/miplay 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +4 -2
  2. package/dist/MAGPIE-LICENSE.txt +21 -0
  3. package/dist/assets/airplay-0f650dbf.png +0 -0
  4. package/dist/assets/index-c3d52e7b.js +1 -0
  5. package/dist/assets/index-cf41e0aa.css +1 -0
  6. package/dist/assets/mina-f2e7977b.png +0 -0
  7. package/dist/assets/miplay-6539f915.js +124 -0
  8. package/dist/assets/miplay-70349e65.png +0 -0
  9. package/dist/assets/miplay-c5d217a1.css +1 -0
  10. package/dist/assets/semi-595e39af.ico +0 -0
  11. package/dist/assets/semi-core-38c824f6.png +0 -0
  12. package/dist/assets/tray-59cb5e08.js +1 -0
  13. package/dist/assets/tray-d30ea4dd.css +1 -0
  14. package/dist/background/main.cjs +19658 -0
  15. package/dist/background/playfair.wasm +0 -0
  16. package/dist/background/vendor/LICENSE +201 -0
  17. package/dist/background/vendor/NOTICE +22 -0
  18. package/dist/background/vendor/README.md +20 -0
  19. package/dist/background/vendor/alac.js +87 -0
  20. package/dist/background/vendor/alacDecoder.js +317 -0
  21. package/dist/background/vendor/appleKey.js +61 -0
  22. package/dist/background/vendor/ntpTiming.js +99 -0
  23. package/dist/background/vendor/package.json +1 -0
  24. package/dist/background/vendor/playfair/BUILD.md +17 -0
  25. package/dist/background/vendor/playfair/LICENSE.md +637 -0
  26. package/dist/background/vendor/playfair/MUSL-COPYRIGHT +193 -0
  27. package/dist/background/vendor/playfair/README.md +24 -0
  28. package/dist/background/vendor/playfair/hand_garble.c +443 -0
  29. package/dist/background/vendor/playfair/modified_md5.c +119 -0
  30. package/dist/background/vendor/playfair/omg_hax.c +540 -0
  31. package/dist/background/vendor/playfair/omg_hax.h +32 -0
  32. package/dist/background/vendor/playfair/playfair.c +31 -0
  33. package/dist/background/vendor/playfair/playfair.h +6 -0
  34. package/dist/background/vendor/playfair/sap_hash.c +96 -0
  35. package/dist/background/vendor/playfair/wasm-wrapper.c +22 -0
  36. package/dist/background/vendor/receiver.js +677 -0
  37. package/dist/icon-dark.svg +1 -0
  38. package/dist/icon.svg +1 -0
  39. package/dist/index.html +6 -0
  40. package/dist/licenses/@leichtgewicht/ip-codec/LICENSE +21 -0
  41. package/dist/licenses/@mediabunny/aac-encoder/LICENSE +373 -0
  42. package/dist/licenses/array-flatten/LICENSE +21 -0
  43. package/dist/licenses/bonjour/LICENSE +21 -0
  44. package/dist/licenses/buffer-indexof/LICENSE +20 -0
  45. package/dist/licenses/call-bind/LICENSE +21 -0
  46. package/dist/licenses/call-bind-apply-helpers/LICENSE +21 -0
  47. package/dist/licenses/call-bound/LICENSE +21 -0
  48. package/dist/licenses/deep-equal/LICENSE +21 -0
  49. package/dist/licenses/define-data-property/LICENSE +21 -0
  50. package/dist/licenses/define-properties/LICENSE +21 -0
  51. package/dist/licenses/dns-equal/LICENSE +21 -0
  52. package/dist/licenses/dns-packet/LICENSE +21 -0
  53. package/dist/licenses/dns-txt/LICENSE +21 -0
  54. package/dist/licenses/dunder-proto/LICENSE +21 -0
  55. package/dist/licenses/es-define-property/LICENSE +21 -0
  56. package/dist/licenses/es-errors/LICENSE +21 -0
  57. package/dist/licenses/es-object-atoms/LICENSE +21 -0
  58. package/dist/licenses/ffmpeg/COPYING.LGPLv2.1 +502 -0
  59. package/dist/licenses/ffmpeg/LICENSE.md +127 -0
  60. package/dist/licenses/function-bind/LICENSE +20 -0
  61. package/dist/licenses/functions-have-names/LICENSE +21 -0
  62. package/dist/licenses/get-intrinsic/LICENSE +21 -0
  63. package/dist/licenses/get-proto/LICENSE +21 -0
  64. package/dist/licenses/gopd/LICENSE +21 -0
  65. package/dist/licenses/has-property-descriptors/LICENSE +21 -0
  66. package/dist/licenses/has-symbols/LICENSE +21 -0
  67. package/dist/licenses/has-tostringtag/LICENSE +21 -0
  68. package/dist/licenses/hasown/LICENSE +21 -0
  69. package/dist/licenses/is-arguments/LICENSE +20 -0
  70. package/dist/licenses/is-date-object/LICENSE +22 -0
  71. package/dist/licenses/is-regex/LICENSE +20 -0
  72. package/dist/licenses/magpie-MIT.txt +21 -0
  73. package/dist/licenses/math-intrinsics/LICENSE +21 -0
  74. package/dist/licenses/mediabunny/LICENSE +373 -0
  75. package/dist/licenses/mediabunny-MPL-2.0.txt +373 -0
  76. package/dist/licenses/multicast-dns/LICENSE +21 -0
  77. package/dist/licenses/multicast-dns-service-types/LICENSE +21 -0
  78. package/dist/licenses/object-is/LICENSE +20 -0
  79. package/dist/licenses/object-keys/LICENSE +21 -0
  80. package/dist/licenses/regexp.prototype.flags/LICENSE +22 -0
  81. package/dist/licenses/set-function-length/LICENSE +21 -0
  82. package/dist/licenses/set-function-name/LICENSE +21 -0
  83. package/dist/licenses/thunky/LICENSE +21 -0
  84. package/dist/tray.html +5 -0
  85. package/package.json +93 -5
@@ -0,0 +1,31 @@
1
+ #include <stdint.h>
2
+
3
+ #include "playfair.h"
4
+
5
+ void generate_key_schedule(unsigned char* key_material, uint32_t key_schedule[11][4]);
6
+ void generate_session_key(unsigned char* oldSap, unsigned char* messageIn, unsigned char* sessionKey);
7
+ void cycle(unsigned char* block, uint32_t key_schedule[11][4]);
8
+ void z_xor(unsigned char* in, unsigned char* out, int blocks);
9
+ void x_xor(unsigned char* in, unsigned char* out, int blocks);
10
+
11
+ extern unsigned char default_sap[];
12
+
13
+ void playfair_decrypt(unsigned char* message3, unsigned char* cipherText, unsigned char* keyOut)
14
+ {
15
+ unsigned char* chunk1 = &cipherText[16];
16
+ unsigned char* chunk2 = &cipherText[56];
17
+ int i;
18
+ unsigned char blockIn[16];
19
+ unsigned char sapKey[16];
20
+ uint32_t key_schedule[11][4];
21
+ generate_session_key(default_sap, message3, sapKey);
22
+ generate_key_schedule(sapKey, key_schedule);
23
+ z_xor(chunk2, blockIn, 1);
24
+ cycle(blockIn, key_schedule);
25
+ for (i = 0; i < 16; i++) {
26
+ keyOut[i] = blockIn[i] ^ chunk1[i];
27
+ }
28
+ x_xor(keyOut, keyOut, 1);
29
+ z_xor(keyOut, keyOut, 1);
30
+ }
31
+
@@ -0,0 +1,6 @@
1
+ #ifndef PLAYFAIR_H
2
+ #define PLAYFAIR_H
3
+
4
+ void playfair_decrypt(unsigned char* message3, unsigned char* cipherText, unsigned char* keyOut);
5
+
6
+ #endif
@@ -0,0 +1,96 @@
1
+ #include <stdint.h>
2
+ #include <stdio.h>
3
+ #include <stdlib.h>
4
+
5
+ #define printf(...) (void)0;
6
+
7
+ void garble(unsigned char*, unsigned char*, unsigned char*, unsigned char*, unsigned char*);
8
+
9
+ unsigned char rol8(unsigned char input, int count)
10
+ {
11
+ return ((input << count) & 0xff) | (input & 0xff) >> (8-count);
12
+ }
13
+
14
+ uint32_t rol8x(unsigned char input, int count)
15
+ {
16
+ return ((input << count)) | (input) >> (8-count);
17
+ }
18
+
19
+
20
+ void sap_hash(unsigned char* blockIn, unsigned char* keyOut)
21
+ {
22
+ uint32_t* block_words = (uint32_t*)blockIn;
23
+ uint32_t* out_words = (uint32_t*)keyOut;
24
+ unsigned char buffer0[20] = {0x96, 0x5F, 0xC6, 0x53, 0xF8, 0x46, 0xCC, 0x18, 0xDF, 0xBE, 0xB2, 0xF8, 0x38, 0xD7, 0xEC, 0x22, 0x03, 0xD1, 0x20, 0x8F};
25
+ unsigned char buffer1[210];
26
+ unsigned char buffer2[35] = {0x43, 0x54, 0x62, 0x7A, 0x18, 0xC3, 0xD6, 0xB3, 0x9A, 0x56, 0xF6, 0x1C, 0x14, 0x3F, 0x0C, 0x1D, 0x3B, 0x36, 0x83, 0xB1, 0x39, 0x51, 0x4A, 0xAA, 0x09, 0x3E, 0xFE, 0x44, 0xAF, 0xDE, 0xC3, 0x20, 0x9D, 0x42, 0x3A};
27
+ unsigned char buffer3[132];
28
+ unsigned char buffer4[21] = {0xED, 0x25, 0xD1, 0xBB, 0xBC, 0x27, 0x9F, 0x02, 0xA2, 0xA9, 0x11, 0x00, 0x0C, 0xB3, 0x52, 0xC0, 0xBD, 0xE3, 0x1B, 0x49, 0xC7};
29
+ int i0_index[11] = {18, 22, 23, 0, 5, 19, 32, 31, 10, 21, 30};
30
+ uint8_t w,x,y,z;
31
+ int i, j;
32
+
33
+ // Load the input into the buffer
34
+ for (i = 0; i < 210; i++)
35
+ {
36
+ // We need to swap the byte order around so it is the right endianness
37
+ uint32_t in_word = block_words[((i % 64)>>2)];
38
+ uint32_t in_byte = (in_word >> ((3-(i % 4)) << 3)) & 0xff;
39
+ buffer1[i] = in_byte;
40
+ }
41
+ // Next a scrambling
42
+ for (i = 0; i < 840; i++)
43
+ {
44
+ // We have to do unsigned, 32-bit modulo, or we get the wrong indices
45
+ x = buffer1[((i-155) & 0xffffffff) % 210];
46
+ y = buffer1[((i-57) & 0xffffffff) % 210];
47
+ z = buffer1[((i-13) & 0xffffffff) % 210];
48
+ w = buffer1[(i & 0xffffffff) % 210];
49
+ buffer1[i % 210] = (rol8(y, 5) + (rol8(z, 3) ^ w) - rol8(x,7)) & 0xff;
50
+ }
51
+ printf("Garbling...\n");
52
+ // I have no idea what this is doing (yet), but it gives the right output
53
+ garble(buffer0, buffer1, buffer2, buffer3, buffer4);
54
+
55
+ // Fill the output with 0xE1
56
+ for (i = 0; i < 16; i++)
57
+ keyOut[i] = 0xE1;
58
+
59
+ // Now we use all the buffers we have calculated to grind out the output. First buffer3
60
+ for (i = 0; i < 11; i++)
61
+ {
62
+ // Note that this is addition (mod 255) and not XOR
63
+ // Also note that we only use certain indices
64
+ // And that index 3 is hard-coded to be 0x3d (Maybe we can hack this up by changing buffer3[0] to be 0xdc?
65
+ if (i == 3)
66
+ keyOut[i] = 0x3d;
67
+ else
68
+ keyOut[i] = ((keyOut[i] + buffer3[i0_index[i] * 4]) & 0xff);
69
+ }
70
+
71
+ // Then buffer0
72
+ for (i = 0; i < 20; i++)
73
+ keyOut[i % 16] ^= buffer0[i];
74
+
75
+ // Then buffer2
76
+ for (i = 0; i < 35; i++)
77
+ keyOut[i % 16] ^= buffer2[i];
78
+
79
+ // Do buffer1
80
+ for (i = 0; i < 210; i++)
81
+ keyOut[(i % 16)] ^= buffer1[i];
82
+
83
+
84
+ // Now we do a kind of reverse-scramble
85
+ for (j = 0; j < 16; j++)
86
+ {
87
+ for (i = 0; i < 16; i++)
88
+ {
89
+ x = keyOut[((i-7) & 0xffffffff) % 16];
90
+ y = keyOut[i % 16];
91
+ z = keyOut[((i-37) & 0xffffffff) % 16];
92
+ w = keyOut[((i-177) & 0xffffffff) % 16];
93
+ keyOut[i] = rol8(x, 1) ^ y ^ rol8(z, 6) ^ rol8(w, 5);
94
+ }
95
+ }
96
+ }
@@ -0,0 +1,22 @@
1
+ /* SPDX-License-Identifier: GPL-3.0-only
2
+ * Semi's fixed-size WASM boundary. No account, network, filesystem or logging API.
3
+ */
4
+ #include <stdint.h>
5
+ #include "playfair.h"
6
+ static unsigned char message[164], wrapped[72], output[16];
7
+ uint32_t key_message_buffer(void) { return (uint32_t)(uintptr_t)message; }
8
+ uint32_t wrapped_key_buffer(void) { return (uint32_t)(uintptr_t)wrapped; }
9
+ uint32_t plain_key_buffer(void) { return (uint32_t)(uintptr_t)output; }
10
+ int unwrap_key(void) {
11
+ if (message[12] > 3) return -1;
12
+ playfair_decrypt(message, wrapped, output);
13
+ return 0;
14
+ }
15
+ void wipe_key_buffers(void) {
16
+ volatile unsigned char *p = message;
17
+ for (unsigned i = 0; i < sizeof(message); i++) p[i] = 0;
18
+ p = wrapped;
19
+ for (unsigned i = 0; i < sizeof(wrapped); i++) p[i] = 0;
20
+ p = output;
21
+ for (unsigned i = 0; i < sizeof(output); i++) p[i] = 0;
22
+ }