aboutsummaryrefslogtreecommitdiff
path: root/third_party/libuweave/src/macaroon_caveat_internal.h
blob: 46a72fbeb9d35c8758db0bc6b41fd8a8facf3dc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2015 The Weave Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef LIBUWEAVE_SRC_MACAROON_CAVEAT_INTERNAL_H_
#define LIBUWEAVE_SRC_MACAROON_CAVEAT_INTERNAL_H_

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

#include "src/macaroon.h"
#include "src/macaroon_caveat.h"

bool uw_macaroon_caveat_sign_(const uint8_t* key,
                              size_t key_len,
                              const UwMacaroonContext* context,
                              const UwMacaroonCaveat* caveat,
                              uint8_t* mac_tag,
                              size_t mac_tag_size);

typedef struct {
  bool has_issued_time;
  uint32_t issued_time;
} UwMacaroonValidationState;

bool uw_macaroon_caveat_init_validation_state_(
    UwMacaroonValidationState* state);

bool uw_macaroon_caveat_validate_(const UwMacaroonCaveat* caveat,
                                  const UwMacaroonContext* context,
                                  UwMacaroonValidationState* state,
                                  UwMacaroonValidationResult* result);

bool uw_macaroon_caveat_get_value_uint_(const UwMacaroonCaveat* caveat,
                                        uint32_t* unsigned_int);
bool uw_macaroon_caveat_get_value_bstr_(const UwMacaroonCaveat* caveat,
                                        const uint8_t** str,
                                        size_t* str_len);

#endif  // LIBUWEAVE_SRC_MACAROON_CAVEAT_INTERNAL_H_