1 // Copyright 2015 The Weave Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef LIBUWEAVE_SRC_MACAROON_CAVEAT_INTERNAL_H_
6 #define LIBUWEAVE_SRC_MACAROON_CAVEAT_INTERNAL_H_
7 
8 #include <stdbool.h>
9 #include <stddef.h>
10 #include <stdint.h>
11 
12 #include "src/macaroon.h"
13 #include "src/macaroon_caveat.h"
14 
15 bool uw_macaroon_caveat_sign_(const uint8_t* key,
16                               size_t key_len,
17                               const UwMacaroonContext* context,
18                               const UwMacaroonCaveat* caveat,
19                               uint8_t* mac_tag,
20                               size_t mac_tag_size);
21 
22 typedef struct {
23   uint32_t issued_time;  // 0 when invalid or not set.
24 } UwMacaroonValidationState;
25 
26 bool uw_macaroon_caveat_init_validation_state_(
27     UwMacaroonValidationState* state);
28 
29 bool uw_macaroon_caveat_validate_(const UwMacaroonCaveat* caveat,
30                                   const UwMacaroonContext* context,
31                                   UwMacaroonValidationState* state,
32                                   UwMacaroonValidationResult* result);
33 
34 bool uw_macaroon_caveat_get_value_uint_(const UwMacaroonCaveat* caveat,
35                                         uint32_t* unsigned_int);
36 bool uw_macaroon_caveat_get_value_bstr_(const UwMacaroonCaveat* caveat,
37                                         const uint8_t** str,
38                                         size_t* str_len);
39 
40 #endif  // LIBUWEAVE_SRC_MACAROON_CAVEAT_INTERNAL_H_
41