2017-09-25 59 views

回答

2

簡答:不,它不是一個可動態插拔的系統。

AES加密是烘焙realm-core,共享庫C++,在編譯時和使用的各種平臺加密功能可用(OS /硬件爲基礎的)。它是開源的,所以理論上你可以編寫一個不同的提供者,並根據需要處理對realm::util::encryption_read_barrierrealm::util::encryption_write_barrier等方法的更改......或者可能根據您的自定義加密要求與Realm簽訂付費合同。

回覆:https://github.com/realm/realm-core/blob/master/src/realm/util/aes_cryptor.hpp

class AESCryptor { 
public: 
    AESCryptor(const uint8_t* key); 
    ~AESCryptor() noexcept; 

    void set_file_size(off_t new_size); 

    bool read(FileDesc fd, off_t pos, char* dst, size_t size); 
    void write(FileDesc fd, off_t pos, const char* src, size_t size) noexcept; 

private: 
    enum EncryptionMode { 
#if REALM_PLATFORM_APPLE 
     mode_Encrypt = kCCEncrypt, 
     mode_Decrypt = kCCDecrypt 
#elif defined(_WIN32) 
     mode_Encrypt = 0, 
     mode_Decrypt = 1 
#else 
     mode_Encrypt = AES_ENCRYPT, 
     mode_Decrypt = AES_DECRYPT 
#endif 
    }; 

#if REALM_PLATFORM_APPLE 
    CCCryptorRef m_encr; 
    CCCryptorRef m_decr; 
#elif defined(_WIN32) 
    BCRYPT_KEY_HANDLE m_aes_key_handle; 
#else 
    AES_KEY m_ectx; 
    AES_KEY m_dctx; 
#endif 

    uint8_t m_hmacKey[32]; 
    std::vector<iv_table> m_iv_buffer; 
    std::unique_ptr<char[]> m_rw_buffer; 
    std::unique_ptr<char[]> m_dst_buffer; 

    void calc_hmac(const void* src, size_t len, uint8_t* dst, const uint8_t* key) const; 
    bool check_hmac(const void* data, size_t len, const uint8_t* hmac) const; 
    void crypt(EncryptionMode mode, off_t pos, char* dst, const char* src, const char* stored_iv) noexcept; 
    iv_table& get_iv_table(FileDesc fd, off_t data_pos) noexcept; 
}; 
相關問題