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

Side by Side Diff: syzygy/experimental/protect/protect_lib/protect_util.cc

Issue 2535563002: Added all code for integrity check transform (Closed)
Patch Set: Created 4 years 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
OLDNEW
(Empty)
1 // Copyright 2015 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 #include "syzygy/protect/protect_lib/protect_util.h"
16 #include <algorithm>
17 #include <ctime>
18 #include <iostream>
19 #include <vector>
20
21 unsigned int VectGenerator::_kSum = 256;
22
23 std::vector<uint8>* VectGenerator::Generate(uint8 x, int len)
24 {
25 unsigned int max_sum = _kSum - x;
26 int rand_num;
27 std::vector<uint8> *values = new std::vector<uint8>();
28
29 if (max_sum < 0) {
30 return NULL;
31 }
32
33 std::srand(unsigned(std::time(0)));
34
35 for (int i = 0; i < len - 1; ++i) {
36 rand_num = std::rand() % max_sum;
37 values->push_back(rand_num);
38
39 max_sum -= rand_num;
40
41 if (max_sum < 0) {
42 return NULL;
43 }
44 }
45
46 values->push_back(max_sum);
47
48 std::random_shuffle(values->begin(), values->end());
49
50 return values;
51 }
OLDNEW
« no previous file with comments | « syzygy/experimental/protect/protect_lib/protect_util.h ('k') | syzygy/experimental/protect/protect_lib/protect_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698