10afa8e06SEd Maste /*
20afa8e06SEd Maste * Copyright (c) 2018 Yubico AB. All rights reserved.
30afa8e06SEd Maste * Use of this source code is governed by a BSD-style
40afa8e06SEd Maste * license that can be found in the LICENSE file.
5*2ccfa855SEd Maste * SPDX-License-Identifier: BSD-2-Clause
60afa8e06SEd Maste */
70afa8e06SEd Maste
80afa8e06SEd Maste #include "fido.h"
90afa8e06SEd Maste
100afa8e06SEd Maste int
fido_buf_read(const unsigned char ** buf,size_t * len,void * dst,size_t count)110afa8e06SEd Maste fido_buf_read(const unsigned char **buf, size_t *len, void *dst, size_t count)
120afa8e06SEd Maste {
130afa8e06SEd Maste if (count > *len)
140afa8e06SEd Maste return (-1);
150afa8e06SEd Maste
160afa8e06SEd Maste memcpy(dst, *buf, count);
170afa8e06SEd Maste *buf += count;
180afa8e06SEd Maste *len -= count;
190afa8e06SEd Maste
200afa8e06SEd Maste return (0);
210afa8e06SEd Maste }
220afa8e06SEd Maste
230afa8e06SEd Maste int
fido_buf_write(unsigned char ** buf,size_t * len,const void * src,size_t count)240afa8e06SEd Maste fido_buf_write(unsigned char **buf, size_t *len, const void *src, size_t count)
250afa8e06SEd Maste {
260afa8e06SEd Maste if (count > *len)
270afa8e06SEd Maste return (-1);
280afa8e06SEd Maste
290afa8e06SEd Maste memcpy(*buf, src, count);
300afa8e06SEd Maste *buf += count;
310afa8e06SEd Maste *len -= count;
320afa8e06SEd Maste
330afa8e06SEd Maste return (0);
340afa8e06SEd Maste }
35