~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/pagespeed/kernel/base/signature.h

  • Committer: Vivian
  • Date: 2015-12-04 18:20:11 UTC
  • Revision ID: git-v1:a36f2bc32e884f7473b3a47040e5411306144d7d
* Do not extract psol.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2014 Google Inc.
3
 
 *
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
7
 
 *
8
 
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 
 *
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.
15
 
 */
16
 
 
17
 
// Author: jcrowell@google.com (Jeffrey Crowell)
18
 
//
19
 
// Interface for a signature function.
20
 
 
21
 
#ifndef PAGESPEED_KERNEL_BASE_SIGNATURE_H_
22
 
#define PAGESPEED_KERNEL_BASE_SIGNATURE_H_
23
 
 
24
 
#include "pagespeed/kernel/base/basictypes.h"
25
 
#include "pagespeed/kernel/base/string.h"
26
 
#include "pagespeed/kernel/base/string_util.h"
27
 
 
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.
34
 
//
35
 
 
36
 
#ifndef ENABLE_URL_SIGNATURES
37
 
#define ENABLE_URL_SIGNATURES 1
38
 
#endif
39
 
 
40
 
namespace net_instaweb {
41
 
 
42
 
class Signature {
43
 
 public:
44
 
  // The passed in max_chars will be used to limit the length of Sign() and
45
 
  // SignatureSizeInChars().
46
 
  explicit Signature();
47
 
  virtual ~Signature();
48
 
 
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;
54
 
 
55
 
  // Returns the string length of the signatures produced by the Sign() method.
56
 
  virtual int SignatureSizeInChars() const = 0;
57
 
 
58
 
 protected:
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;
63
 
 
64
 
 private:
65
 
  DISALLOW_COPY_AND_ASSIGN(Signature);
66
 
};
67
 
 
68
 
} // namespace net_instaweb
69
 
 
70
 
 
71
 
#endif  // PAGESPEED_KERNEL_BASE_SIGNATURE_H_