1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef __RPMB_H__ 18 #define __RPMB_H__ 19 20 #include <stdbool.h> 21 #include <stddef.h> 22 #include <stdint.h> 23 24 struct rpmb_key { 25 uint8_t byte[32]; 26 }; 27 28 struct rpmb_state; 29 30 #define RPMB_BUF_SIZE 256 31 32 /* provides */ 33 int rpmb_init(struct rpmb_state** statep, 34 void* mmc_handle, 35 const struct rpmb_key* key); 36 void rpmb_uninit(struct rpmb_state* statep); 37 int rpmb_read(struct rpmb_state* state, 38 void* buf, 39 uint16_t addr, 40 uint16_t count); 41 /* count must be 1 or 2, addr must be aligned */ 42 int rpmb_write(struct rpmb_state* state, 43 const void* buf, 44 uint16_t addr, 45 uint16_t count, 46 bool sync); 47 48 /* needs */ 49 int rpmb_send(void* mmc_handle, 50 void* reliable_write_buf, 51 size_t reliable_write_size, 52 void* write_buf, 53 size_t write_buf_size, 54 void* read_buf, 55 size_t read_buf_size, 56 bool sync); 57 58 #endif 59