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 #pragma once 18 19 #define HWRNG_PORT "com.android.trusty.hwrng" 20 21 /* 22 * The hwrng protocol works as follows: 23 * 1) Client opens channel to the server, then sends one or more 24 * requests and receives replies. 25 * 26 * Client is allowed to keep the channel opened for the duration 27 * of the session. 28 * 29 * Client is allowed to open multiple channels, all such channels 30 * should be treated independently. 31 * 32 * Client is allowed to issue multiple requests over the same channel. 33 * 34 * 2) Server queues requests, and may reply with data as it 35 * is retrieved. 36 * 37 * The response is comprised of only bytes of random data. No 38 * protocol header is provided. 39 * 40 * Server is allowed to combine such requests together and return all 41 * results in a single message. 42 * 43 * Server is allowed to return requested RNG data as a series of smaller 44 * chunks at it finds fit. 45 */ 46 47 /** 48 * struct hwrng_req - Request structure for communicating with the hardware RNG 49 * @len: the length in bytes of random data requested 50 * 51 */ 52 struct hwrng_req { 53 uint32_t len; 54 }; 55