Lines Matching refs:view

78     DataView view = {.buffer = {}, .data = input, .start = 0, .length = input.size()};  in update()  local
79 keymaster_error_t err = bufferData(view); in update()
85 if (view.length > MAX_CHUNK_SIZE) { in update()
86 err = updateInChunks(view, aToken, tToken, output); in update()
91 vector<uint8_t> remaining = popNextChunk(view, view.length); in update()
107 DataView view = {.buffer = {}, .data = inData, .start = 0, .length = inData.size()}; in finish() local
111 appendBufferedData(view); in finish()
112 if (view.length > MAX_CHUNK_SIZE) { in finish()
113 auto err = updateInChunks(view, aToken, tToken, output); in finish()
119 keymaster_error_t err = bufferData(view); in finish()
123 appendBufferedData(view); in finish()
125 vector<uint8_t> remaining = popNextChunk(view, view.length); in finish()
139 void JavacardKeyMintOperation::blockAlign(DataView& view, uint16_t blockSize) { in blockAlign() argument
140 appendBufferedData(view); in blockAlign()
141 uint16_t offset = getDataViewOffset(view, blockSize); in blockAlign()
142 if (view.buffer.empty() && view.data.empty()) { in blockAlign()
144 } else if (view.buffer.empty()) { in blockAlign()
145 buffer_.insert(buffer_.end(), view.data.begin() + offset, view.data.end()); in blockAlign()
146 } else if (view.data.empty()) { in blockAlign()
147 buffer_.insert(buffer_.end(), view.buffer.begin() + offset, view.buffer.end()); in blockAlign()
149 if (offset < view.buffer.size()) { in blockAlign()
150 buffer_.insert(buffer_.end(), view.buffer.begin() + offset, view.buffer.end()); in blockAlign()
151 buffer_.insert(buffer_.end(), view.data.begin(), view.data.end()); in blockAlign()
153 offset = offset - view.buffer.size(); in blockAlign()
154 buffer_.insert(buffer_.end(), view.data.begin() + offset, view.data.end()); in blockAlign()
158 view.length = view.length - buffer_.size(); in blockAlign()
161 uint16_t JavacardKeyMintOperation::getDataViewOffset(DataView& view, uint16_t blockSize) { in getDataViewOffset() argument
167 offset = ((view.length / blockSize)) * blockSize; in getDataViewOffset()
168 remaining = (view.length % blockSize); in getDataViewOffset()
175 offset = ((view.length / blockSize)) * blockSize; in getDataViewOffset()
178 if (view.length > macLength_) { in getDataViewOffset()
179 offset = (view.length - macLength_); in getDataViewOffset()
188 keymaster_error_t JavacardKeyMintOperation::bufferData(DataView& view) { in bufferData() argument
189 if (view.data.empty()) return KM_ERROR_OK; // nothing to buffer in bufferData()
192 buffer_.insert(buffer_.end(), view.data.begin(), view.data.end()); in bufferData()
197 view.start = 0; in bufferData()
198 view.length = 0; in bufferData()
202 buffer_.insert(buffer_.end(), view.data.begin(), view.data.end()); in bufferData()
208 view.start = 0; in bufferData()
209 view.length = 0; in bufferData()
213 blockAlign(view, AES_BLOCK_SIZE); in bufferData()
216 blockAlign(view, macLength_); in bufferData()
220 blockAlign(view, DES_BLOCK_SIZE); in bufferData()
229 keymaster_error_t JavacardKeyMintOperation::updateInChunks(DataView& view, in updateInChunks() argument
234 while (view.length > MAX_CHUNK_SIZE) { in updateInChunks()
235 vector<uint8_t> chunk = popNextChunk(view, MAX_CHUNK_SIZE); in updateInChunks()
247 vector<uint8_t> JavacardKeyMintOperation::popNextChunk(DataView& view, uint32_t chunkSize) { in popNextChunk() argument
248 uint32_t start = view.start; in popNextChunk()
249 uint32_t end = start + ((view.length < chunkSize) ? view.length : chunkSize); in popNextChunk()
251 if (start < view.buffer.size()) { in popNextChunk()
252 if (end < view.buffer.size()) { in popNextChunk()
253 chunk = {view.buffer.begin() + start, view.buffer.begin() + end}; in popNextChunk()
255 end = end - view.buffer.size(); in popNextChunk()
256 chunk = {view.buffer.begin() + start, view.buffer.end()}; in popNextChunk()
257 chunk.insert(chunk.end(), view.data.begin(), view.data.begin() + end); in popNextChunk()
260 start = start - view.buffer.size(); in popNextChunk()
261 end = end - view.buffer.size(); in popNextChunk()
262 chunk = {view.data.begin() + start, view.data.begin() + end}; in popNextChunk()
264 view.start = view.start + chunk.size(); in popNextChunk()
265 view.length = view.length - chunk.size(); in popNextChunk()