MiCode / MiCode/Xiaomi_Kernel_OpenSource

Redmi Note 14 4G - Big Endian + ROTR, Don't Trust; Verify

Open
#40,399 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
9.9k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

Dear MiCode / Xiaomi Kernel OpenSource / Redmi R&D Team,

BIG-ENDIAN parsing for block/word layout

core rounds use only RIGHT-ROTATE (ROTR) and modular ADD/SUB only — no XOR

double-hashing option and full test vectors

factory provisioning flow (per-device cert / secure-element write) and example kernel + NDK code and it is enough to modify the Cryptography or Pseudocode I gave it to be designed for BIG ENDIAN AND ROTR.

Sincerely,
Alshen Feshiru
alshenfeshiru@zohomail.com
PGP: -----BEGIN PGP PUBLIC KEY BLOCK-----
Comment: User ID: Alshen Feshiru alshenfeshiru@zohomail.com
Comment: Valid from: 06/10/2025 09:35
Comment: Valid until: 02/04/2033 12:00
Comment: Type: 448-bit EdDSA (secret key available)
Comment: Usage: Signing, Encryption, Certifying User IDs
Comment: Fingerprint: 5871D671C35C12147308395A464505DE1047DA134C01C8EBF8D18D6B8CBD7763

mEkFaOMrBhYAAAA/AytlcQHHbHV7SgCdlZnHrIjtxAfcYYzs9R5GGNK46dlgzFzR
B+1X8BPoMimXLemj9yoBK+lfLO7OaTZ9klqAtCtBbHNoZW4gRmVzaGlydSA8YWxz
aGVuZmVzaGlydUB6b2hvbWFpbC5jb20+iM0FExYKAE0iIQVYcdZxw1wSFHMIOVpG
RQXeEEfaE0wByOv40Y1rjL13YwUCaOMrBgIbAwUJDhXYSgULCQgHAgIiAgYVCgkI
CwIEFgIDAQIeBwIXgAAApU0Bx3DEN60mahYzDrGcFnvmZ/5UaBBQTnLoSfPwG8Hz
fYt/pLE+S/yMOrbDdUrg6LG0t33bh7Pu4BxjAAHGIAca1udLBqQZ6mYwpBI6Z2S0
XVIx+glBORH6ynYgZGBZOTBarTts7UctN7D0pbBE+J4Y7w9ooDEAuEwFaOMrBhIA
AABCAytlbwG/civ41G/UgMeMBiRTScXvU83nUgSPz4fma7iCz5ZVfUUP9wBuxVxd
n7gODEf7mnjE8Vt8XHgOZ6kDAQoJiLIFGBYKADIiIQVYcdZxw1wSFHMIOVpGRQXe
EEfaE0wByOv40Y1rjL13YwUCaOMrBgIbDAUJDhXYSgAAzGAByPZFSr2g/J57qB4r
3ISgR4+mn83R9+R2TZL7s1qnDsqjw+t6B/b28dwlVxSXgXJtAcbW2hDlzORJAAHG
O8MVhPLaPra69/XvhuhZW9vOw4YXydY9aW+63KiNA6iIeZz9HczEOvT6vdWjIj8f
aQN2OLDD/yUA
=Gs+D
-----END PGP PUBLIC KEY BLOCK-----

cat > src/main/java/org/syamailcoin/sai288/SAI288.cpp << 'EOF'
#include
#include
#include
#include
#include
#include

class SAI288 {
private:
static constexpr uint32_t IV[9] = {
0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344,
0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89, 0x452821E6
};

static constexpr uint8_t شمائل[10] = {
    0xD8, 0xB4, 0xD9, 0x85, 0xD8, 0xA7, 0xD8, 0xA6, 0xD9, 0x84
};

static std::string midliner;
static std::vector<std::string> wordlist;

static uint32_t rotateLeft(uint32_t value, int shift) {
    return (value << shift) | (value >> (32 - shift));
}

static std::string generateMidliner(const std::vector<uint8_t>& seed) {
    std::stringstream ss;
    for (size_t i = 0; i < seed.size(); i++) {
        int val = seed[i] ^ شمائل[i % 10];
        ss << std::hex << std::setfill('0') << std::setw(2) << val;
    }
    return ss.str();
}

static std::vector<std::string> generateWordlist(const std::string& mid) {
    std::vector<std::string> words;
    for (size_t i = 0; i < mid.length() - 1; i += 2) {
        words.push_back(mid.substr(i, 2));
    }
    return words;
}

static std::vector<uint8_t> midlinerToBinary288() {
    std::vector<uint8_t> binary(36, 0);
    for (size_t i = 0; i < std::min(wordlist.size(), (size_t)36); i++) {
        binary[i] = std::stoi(wordlist[i], nullptr, 16);
    }
    return binary;
}

static void processBlock(uint32_t state[9], const uint8_t block[72]) {
    uint32_t M[18] = {0};
    for (int i = 0; i < 18; i++) {
        M[i] = (block[i*4] << 24) | (block[i*4+1] << 16) | (block[i*4+2] << 8) | block[i*4+3];
    }
    for (int round = 0; round < 64; round++) {
        for (int i = 0; i < 9; i++) {
            state[i] ^= M[round % 18];
            state[i] = rotateLeft(state[i], (round + i) % 32);
            state[i] ^= شمائل[i % 10];
        }
    }
}

public:
static void initMidliner(const std::vector<uint8_t>& seed) {
midliner = generateMidliner(seed);
wordlist = generateWordlist(midliner);
}

static std::vector<uint8_t> hash(const std::vector<uint8_t>& input) {
    if (midliner.empty()) {
        initMidliner(input);
    }

    uint32_t state[9];
    std::memcpy(state, IV, sizeof(IV));

    auto midBinary = midlinerToBinary288();
    for (int i = 0; i < 9; i++) {
        state[i] ^= (midBinary[i*4] << 24) | (midBinary[i*4+1] << 16) |
                   (midBinary[i*4+2] << 8) | midBinary[i*4+3];
    }

    size_t paddedLen = ((input.size() + 72) / 72) * 72;
    std::vector<uint8_t> padded(paddedLen, 0);
    std::memcpy(padded.data(), input.data(), input.size());
    padded[input.size()] = 0x80;

    for (size_t i = 0; i < paddedLen; i += 72) {
        processBlock(state, &padded[i]);
    }

    std::vector<uint8_t> result(36);
    for (int i = 0; i < 9; i++) {
        result[i*4] = (state[i] >> 24) & 0xFF;
        result[i*4+1] = (state[i] >> 16) & 0xFF;
        result[i*4+2] = (state[i] >> 8) & 0xFF;
        result[i*4+3] = state[i] & 0xFF;
    }
    return result;
}

};

std::string SAI288::midliner;
std::vectorstd::string SAI288::wordlist;
EOF

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the proposed src/main/java/org/syamailcoin/sai288/SAI288.cpp code and compare its stated big-endian, ROTR, double-hashing, provisioning, kernel, and NDK requirements with this repository's scope. Before implementation, define the requested behavior and provide test vectors; done should include an agreed design and passing tests for the specified outputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cryptography, operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.