1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "tls_parser.h"
11 bool TlsParser::Read(uint8_t* val
) {
12 if (remaining() < 1) {
20 bool TlsParser::Read(uint32_t* val
, size_t size
) {
21 if (size
> sizeof(uint32_t)) {
26 for (size_t i
= 0; i
< size
; ++i
) {
39 bool TlsParser::Read(DataBuffer
* val
, size_t len
) {
40 if (remaining() < len
) {
44 val
->Assign(ptr(), len
);
49 bool TlsParser::ReadFromMark(DataBuffer
* val
, size_t len
, size_t mark
) {
53 if (remaining() < len
) {
58 val
->Assign(ptr(), len
);
64 bool TlsParser::ReadVariable(DataBuffer
* val
, size_t len_size
) {
66 if (!Read(&len
, len_size
)) {
69 return Read(val
, len
);
72 bool TlsParser::Skip(size_t len
) {
73 if (len
> remaining()) {
80 bool TlsParser::SkipVariable(size_t len_size
) {
82 if (!Read(&len
, len_size
)) {
88 } // namespace nss_test