Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: base/security/rsa.h

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/security/rc4.c ('k') | base/security/rsa.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2006-2009 Google Inc.
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
16 #ifndef OMAHA_COMMON_SECURITY_RSA_H__
17 #define OMAHA_COMMON_SECURITY_RSA_H__
18
19 #include <inttypes.h>
20
21 class RSA {
22 public:
23 typedef const uint32_t PublicKeyInstance[];
24 typedef const uint32_t* PublicKey;
25
26 // Public_key as montgomery precomputed array
27 explicit RSA(PublicKey public_key) : pkey_(public_key) {}
28
29 // Verifies a Google style RSA message recovery signature.
30 //
31 // sig[] signature to verify, big-endian byte array.
32 // sig_len length of sig[] in bytes.
33 // If verified successfully, output receives the recovered
34 // message and the function returns the number of bytes.
35 // If not successful, the function returns 0.
36 // (empty message is not a useful message)
37 int verify(const uint8_t* sig, int sig_len,
38 void* output, int output_max) const;
39
40 // Hybrid encrypt message.
41 //
42 // output_max should be at least encryptedSize(msg_len)
43 // Returns 0 on failure, # output bytes on success.
44 int encrypt(const uint8_t* msg, int msg_len,
45 const void* seed, int seed_len,
46 uint8_t* output, int output_max) const;
47
48 int encryptedSize(int len) const {
49 return len + 1 + 4 + size();
50 }
51
52 // Performs in-place public key exponentiation.
53 //
54 // Input_len should match size of modulus in bytes.
55 // Returns 0 on failure, # of bytes written on success.
56 int raw(uint8_t* input, int input_len) const;
57
58 int version() const { return pkey_[0]; }
59 int size() const { return pkey_[1] * 4; }
60
61 private:
62 const PublicKey pkey_;
63 static const int kMaxWords = 64;
64 };
65
66 #endif // OMAHA_COMMON_SECURITY_RSA_H__
OLDNEW
« no previous file with comments | « base/security/rc4.c ('k') | base/security/rsa.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698