31 prefixLength = prefixL;
33 key =
new unsigned char[keyLength / 8];
43 initKey(prefixL, keyL);
60 memset(key, 0, keyLength / 8);
65 for (
int i = 0; i < keyLength / 8; i++) {
66 if (key[i] != 0)
return true;
83 return memcmp(key,
id.key, keyLength / 8);
88 return compareTo(
id) < 0;
93 return compareTo(
id) > 0;
98 return compareTo(
id) == 0;
103 memcpy(key,
id.key, keyLength / 8);
110 return memcmp(key,
id.key, prefixLength / 8) == 0;
117 for (index = 0; index < keyLength; index++) {
118 if (key[index] !=
id.key[index])
break;
121 return (keyLength - index) * 256 + (key[index] ^
id.key[index]);
136 sha1.
Update((uint8_t*)p.c_str(), p.size());
141 size1 = prefixLength / 8;
142 if (size1 > 20) size1 = 20;
143 memcpy(key, temp, size1);
147 if (o.size() == 0)
return;
152 sha1.
Update((uint8_t*)o.c_str(), o.size());
157 size2 = (keyLength - prefixLength) / 8;
158 if (size2 > 20) size2 = 20;
159 memcpy(key + size1, temp, size2);
164 createRandomPrefix();
165 createRandomSuffix();
170 for (
int i = 0; i < prefixLength / 8; i++) {
171 key[i] = intrand(256);
177 for (
int i = prefixLength / 8; i < keyLength / 8; i++) {
178 key[i] = intrand(256);
183 return 16 + keyLength;
198 const char hex[] =
"0123456789abcdef";
201 if (
id.name.length() != 0) {
202 os <<
"(" <<
id.name <<
") ";
205 for (
int i = 0; i <
id.prefixLength / 8; i++) {
206 os << hex[
id.key[i] >> 4];
207 os << hex[
id.key[i] & 0xf];
212 for (
int i =
id.prefixLength / 8; i <
id.keyLength / 8; i++) {
213 if (
id.key[i] != 0) {
221 for (
int i =
id.prefixLength / 8; i <
id.keyLength / 8; i++) {
222 os << hex[
id.key[i] >> 4];
223 os << hex[
id.key[i] & 0xf];
233 cout <<
"Warning: key already deleted." << endl;