2
* Copyright 2014 Google Inc.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
// Author: jcrowell@google.com (Jeffrey Crowell)
19
// Interface for a signature function.
21
#ifndef PAGESPEED_KERNEL_BASE_SIGNATURE_H_
22
#define PAGESPEED_KERNEL_BASE_SIGNATURE_H_
24
#include "pagespeed/kernel/base/basictypes.h"
25
#include "pagespeed/kernel/base/string.h"
26
#include "pagespeed/kernel/base/string_util.h"
28
// To enable URL signing with HMAC-SHA1, we must link against OpenSSL,
29
// which is a a large library with licensing restrictions not known to
30
// be wholly inline with the Apache license. To disable URL signing:
31
// 1. Set SIGN_URL to 0 here
32
// 2. Comment out the references to openssl.gyp in kernel.gyp.
33
// 3. Comment out all references to openssl in src/DEPS.
36
#ifndef ENABLE_URL_SIGNATURES
37
#define ENABLE_URL_SIGNATURES 1
40
namespace net_instaweb {
44
// The passed in max_chars will be used to limit the length of Sign() and
45
// SignatureSizeInChars().
49
// Computes a web64-encoded signature of data under a given key. Takes a
50
// StringPiece for signing key, which is used for a pointer to the key and the
51
// length of the signing key, and a StringPiece for the data, which is used
52
// for a pointer to the data to sign, and the length of the data.
53
GoogleString Sign(StringPiece key, StringPiece data) const;
55
// Returns the string length of the signatures produced by the Sign() method.
56
virtual int SignatureSizeInChars() const = 0;
59
// Computes a binary signature of a given data under key.
60
virtual GoogleString RawSign(StringPiece key, StringPiece data) const = 0;
61
// The number of bytes RawSign will produce.
62
virtual int RawSignatureSizeInBytes() const = 0;
65
DISALLOW_COPY_AND_ASSIGN(Signature);
68
} // namespace net_instaweb
71
#endif // PAGESPEED_KERNEL_BASE_SIGNATURE_H_