~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/pagespeed/kernel/util/nonce_generator.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
 
// Copyright 2013 Google Inc. All Rights Reserved.
2
 
//
3
 
// Licensed under the Apache License, Version 2.0 (the "License");
4
 
// you may not use this file except in compliance with the License.
5
 
// You may obtain a copy of the License at
6
 
//
7
 
//      http://www.apache.org/licenses/LICENSE-2.0
8
 
//
9
 
// Unless required by applicable law or agreed to in writing, software
10
 
// distributed under the License is distributed on an "AS IS" BASIS,
11
 
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
 
// See the License for the specific language governing permissions and
13
 
// limitations under the License.
14
 
 
15
 
// Author: jmaessen@google.com (Jan-Willem Maessen)
16
 
 
17
 
#ifndef PAGESPEED_KERNEL_UTIL_NONCE_GENERATOR_H_
18
 
#define PAGESPEED_KERNEL_UTIL_NONCE_GENERATOR_H_
19
 
 
20
 
#include "pagespeed/kernel/base/abstract_mutex.h"
21
 
#include "pagespeed/kernel/base/basictypes.h"
22
 
#include "pagespeed/kernel/base/scoped_ptr.h"
23
 
 
24
 
namespace net_instaweb {
25
 
 
26
 
// Abstract base class for a generator of cryptographic nonce values (ie a
27
 
// cryptographic random number generator).
28
 
class NonceGenerator {
29
 
 public:
30
 
  virtual ~NonceGenerator();
31
 
  // Generate a fresh, ideally cryptographic, nonce.  Thread-safe.
32
 
  uint64 NewNonce();
33
 
 
34
 
 protected:
35
 
  // Takes ownership of mutex.
36
 
  explicit NonceGenerator(AbstractMutex* mutex) : mutex_(mutex) { }
37
 
 
38
 
  // Subclasses must implement this method.  Locking is already handled.
39
 
  virtual uint64 NewNonceImpl() = 0;
40
 
 
41
 
 private:
42
 
  scoped_ptr<AbstractMutex> mutex_;
43
 
 
44
 
  DISALLOW_COPY_AND_ASSIGN(NonceGenerator);
45
 
};
46
 
 
47
 
}  // namespace net_instaweb
48
 
 
49
 
#endif  // PAGESPEED_KERNEL_UTIL_NONCE_GENERATOR_H_