|
zootm posted:I don't disagree with that in general but due to Java's general suckiness, passing in a dynamic value like this as a parameter is non-trivial. Unless you want to pass in an implementation of some obscene interface called BlockDispersalCalculator or something, you're stuck. It is a language limitation though, what you suggest is generally sensible. Not that this is relevant to the whole "scripting vs hardcoded" discussion, but in this case (determining how many items drop from a block) it seemslike you could just have a minimum and maximum count for each block type and that would cover every reasonable case.
|
# ? Feb 17, 2011 18:25 |
|
|
# ? May 16, 2024 09:22 |
|
Ugg boots posted:Correct me if I'm wrong, but by passing in a dynamic value you don't mean passing in an enum value do you? Having said that ninjeff's suggestion (which I would quote if I wasn't on a mobile phone) above makes perfect sense assuming people don't want to screw with the distribution.
|
# ? Feb 18, 2011 09:39 |
|
What's the output of this program on your system?code:
|
# ? Feb 21, 2011 03:07 |
|
shrughes posted:What's the output of this program on your system?
|
# ? Feb 21, 2011 03:35 |
|
^^ Why is that? Shouldn't only one F be created, and thus, only one destroyed?
|
# ? Feb 21, 2011 03:36 |
|
ToxicFrog posted:^^ Why is that? Shouldn't only one F be created, and thus, only one destroyed? If map::operator[] is called with a missing key, it automatically inserts a default value with that key before returning its reference. Inserting requires construction of a std::pair<int, F>. The behavior should be something like: 1. call map::operator[] , it constructs a temporary pair, inserts it, then unstacks the temp values (two F deletions) 2. temporary F is created, then assigned to reference returned from operator[], then unstacks the temporary (third F deletion) 3. map::erase() removes the value from the map (fourth F deletion)
|
# ? Feb 21, 2011 03:53 |
|
Janin posted:Should be 4 on any standards-compliant compiler; what number were you expecting? I would expect it to be 2. One for the std::pair field on a tree node, and one for the temporary in main(). There's no reason for it to be higher. (And if the standard says it must be identical to m.insert(make_pair(5, F())).first->second then the standard is a coding horror.)
|
# ? Feb 21, 2011 03:53 |
|
shrughes posted:I would expect it to be 2. There's no reason for it to be higher. (And if the standard says it must be identical to m.insert(make_pair(5, F())).first->second then the standard is a coding horror.)
|
# ? Feb 21, 2011 03:55 |
|
One gets created when evaluating the RHS of the assignment; another gets created when evaluating the LHS of the assignment (i.e., creating an object to assign into). It's not possible to elide copy-assignments, so that's the bare minimum. libstdc++'s std::map requires two more temporaries because it actually implements operator[] in terms of insert(it, value_type(key, mapped_type())) when the key isn't found, which creates a temporary key and *two* temporary values. EDIT: beaten quite badly.
|
# ? Feb 21, 2011 04:04 |
|
http://sourcesale.com/projects/2357-Encryption-Static-Library I haven't seen the source code for it, but the description is bad enough. This is supposed to be a form of encryption? quote:The library gets a password from an array and uses it to create a much bigger array. Then it gets a byte from the data to be encrypted and adds that with a value within the larger array. To use this for file encryption I recommend using the while loop and loop through the file sending data to the library one byte at a time until the file ends.
|
# ? Feb 21, 2011 18:07 |
|
ryanmfw posted:http://sourcesale.com/projects/2357-Encryption-Static-Library Hah, that's awesome. Here's a preview of the code from that page code:
|
# ? Feb 21, 2011 18:49 |
|
Ugg boots posted:Hah, that's awesome. Here's a preview of the code from that page
|
# ? Feb 21, 2011 19:14 |
|
gibbed posted:I RE'd a little bit of the testalib.exe and it appeared to just be XORing the content with a generated table based on the key (this is just from a quick look though, I could be wrong). So yeah, crappy obfuscation. That's how AES-CTR and AES-OFB work, except the table is so fantastically large it's impractical to store.
|
# ? Feb 22, 2011 05:44 |
|
BonzoESC posted:That's how AES-CTR and AES-OFB work, except the table is so fantastically large it's impractical to store.
|
# ? Feb 22, 2011 06:18 |
|
mysql> select aes_encrypt('hello', '') = aes_encrypt('hello', '4re35na2aTaVasAy4re35na2aTaVasAy'); +-------------------------------------------------------------------------------------+ | aes_encrypt('hello', '') = aes_encrypt('hello', '4re35na2aTaVasAy4re35na2aTaVasAy') | +-------------------------------------------------------------------------------------+ | 1 | +-------------------------------------------------------------------------------------+ http://bazaar.launchpad.net/~mysql/mysql-server/mysql-5.5/view/head:/mysys/my_aes.c
|
# ? Feb 23, 2011 01:11 |
|
Aleksei Vasiliev posted:mysql> select aes_encrypt('hello', '') = aes_encrypt('hello', '4re35na2aTaVasAy4re35na2aTaVasAy'); I don't get it. vvv oh, hurr. Opinion Haver fucked around with this message at 01:37 on Feb 23, 2011 |
# ? Feb 23, 2011 01:21 |
|
Aleksei Vasiliev posted:mysql> select aes_encrypt('hello', '') = aes_encrypt('hello', '4re35na2aTaVasAy4re35na2aTaVasAy'); Is that a case of an accidental collision, or a pre-defined default key? yaoi prophet posted:I don't get it bobthecheese fucked around with this message at 01:25 on Feb 23, 2011 |
# ? Feb 23, 2011 01:23 |
|
bobthecheese posted:Is that a case of an accidental collision, or a pre-defined default key?
|
# ? Feb 23, 2011 03:20 |
|
Janin posted:If the key length is >128 bits, MySQL reduces it by XOR. "4re35na2aTaVasAy4re35na2aTaVasAy" is just "4re35na2aTaVasAy" twice, so it reduces to 0 (the same as ""). You can get the same result by doubling (or quadrupling, etc) any 16-character string. Oh, wow, that IS a horror.
|
# ? Feb 23, 2011 03:22 |
|
I can't wait for Oracle to finally kill MySQL
|
# ? Feb 23, 2011 03:33 |
|
Aleksei Vasiliev posted:mysql> select aes_encrypt('hello', '') = aes_encrypt('hello', '4re35na2aTaVasAy4re35na2aTaVasAy');
|
# ? Feb 23, 2011 04:13 |
|
Kelson posted:I'm not sure I'm following where that value arises from the link. In my_aes_create_key, I see that it leaves rkey 0'd out if key_length is 0, but it looks like rijndaelKeySetup* (wherever that's defined) then sets "4re...". Am I missing something?
|
# ? Feb 23, 2011 05:50 |
|
Janin posted:read my post
|
# ? Feb 23, 2011 12:14 |
|
BonzoESC posted:That's how AES-CTR and AES-OFB work, except the table is so fantastically large it's impractical to store.
|
# ? Feb 23, 2011 12:29 |
|
gibbed posted:Well yes, but this self-implemented junk is terrible. It's like, yeah I kinda know how hash functions work, but I sure as poo poo won't try to write one myself!
|
# ? Feb 23, 2011 16:46 |
|
Kelson posted:I did. I didn't say "I don't understand what is happening". Instead, "I'm not following where that value arises from the link." code:
|
# ? Feb 23, 2011 16:59 |
|
Ryouga Inverse posted:
If that weren't the case, the value would be whatever happened to be in the "invalid" memory block key pointed towards (which may change between runs).
|
# ? Feb 24, 2011 04:07 |
|
Kelson posted:That's what I thought at first, except key_length is presumably 0 for the empty string. That means key_end = key + 0, which is really just key. Which skips the for(sptr = key;sptr < key;sptr++) loop? Correct, except the memory block isn't invalid in that case, it's explicitly initialized to zero by the bzero call prior to the block. The value Aleksei Vasiliev chose doesn't come from the code, it's arbitrary. It just happens to have the property that when XORed over itself in 16-byte chunks it becomes zero. The key "4re35na2aTaVasAy4re35na2aTaVasAy" is the same as the key "" is the same as the key "0123456789abcdef0123456789abcdef" is the same as the key "abcdefghijklmnopabcdefghijklmnop" is the same as the key "aaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbb" and so on and so on. ShoulderDaemon fucked around with this message at 04:35 on Feb 24, 2011 |
# ? Feb 24, 2011 04:32 |
|
ShoulderDaemon posted:Correct, except the memory block isn't invalid in that case, it's explicitly initialized to zero by the bzero call prior to the block. code:
ShoulderDaemon posted:The value Aleksei Vasiliev chose doesn't come from the code, it's arbitrary. It just happens to have the property that when XORed over itself in 16-byte chunks it becomes zero. The key "4re35na2aTaVasAy4re35na2aTaVasAy" is the same as the key "" is the same as the key "0123456789abcdef0123456789abcdef" is the same as the key "abcdefghijklmnopabcdefghijklmnop" is the same as the key "aaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbb" and so on and so on.
|
# ? Feb 24, 2011 12:28 |
|
*key is a pointer to the password rkey is an array of length 16 (AES_KEY_LENGTH = 128, /8 = 16. see my_aes.h for the define) rkey is the actual key that will be used to encrypt/decrypt for (ptr= rkey, sptr= key; sptr < key_end; ptr++,sptr++) { if (ptr == rkey_end) ptr= rkey; /* Just loop over tmp_key until we used all key */ *ptr^= (uint8) *sptr; } sptr = the password pointer it first zeroes the realkey, if the given password is 0-length then it's done creating the realkey, the loop doesn't run if not, then it will iterate through the realkey[16] for as many bytes as there are in the password, XORing as it goes. that's this line: *ptr^= (uint8) *sptr;.( ^= is XOR-assignment). if it hits the realkey's end, then it will reset to the beginning of the array. the password index is not changed. did this help (also I'm a Java programmer so my explanation might be totally wrong )
|
# ? Feb 24, 2011 14:25 |
|
I don't see what the problem is. Just use "4re35na2aTaVasAy4re35na2aTaVasAy4re35na2aTaVasAy" and you'll be fine.
|
# ? Feb 24, 2011 16:34 |
|
Kelson posted:If key_length is 0, the for loop never executes (no xor takes place in my_aes_create_key) which leaves rkey bzero'd. Kelson posted:If mysql was retarded and key_length somehow weren't 0 in the empty-key instance above, it'd xor *sptr into rkey, which is "invalid" memory (sptr = key; sptr < key+key_length) not the bzero'd buffer (ptr = rkey; bzero(rkey, AES_KEY_LENGTH/8)). Kelson posted:I believe "4re35na2aTaVasAy" is xor'd into each 16-byte chunk; where is that value in the code above? The only thing that's special about about the key that Aleksei Vasiliev chose is that it consists of a 16-character string, repeated an even number of times. Any such key will be equivalent to the all-zeroes key or the empty key. Kelson posted:I may certainly be missing something, I'm just asking what. It appears to be in code not shown in the link (such as within rijndaelKeySetupEnc(aes_key->rk, rkey, AES_KEY_LENGTH)). No? Nowhere within any of the MySQL code or its support libraries will you find "4re35na2aTaVasAy". It's not a value that comes from the code. It's just a value that Aleksei Vasiliev picked to demonstrate the problem.
|
# ? Feb 24, 2011 17:49 |
|
code:
|
# ? Feb 24, 2011 18:08 |
|
Sheet nigga, that's all you had to say!
|
# ? Feb 24, 2011 18:55 |
|
ToxicFrog posted:Who the gently caress uses floats to store monetary amounts At the risk of sounding stupid, what's that preferred way? VVV hah, I understand how floats are stored and their implicit fuzziness. I meant which variable type or some other method. Randomosity fucked around with this message at 19:57 on Feb 24, 2011 |
# ? Feb 24, 2011 19:50 |
|
Certainly not a format incapable of storing exact values.
|
# ? Feb 24, 2011 19:52 |
|
Store an integer containing cents; doubles are just big floats.
|
# ? Feb 24, 2011 19:58 |
|
rt4 posted:Store an integer containing cents; doubles are just big floats.
|
# ? Feb 24, 2011 20:04 |
|
Randomosity posted:At the risk of sounding stupid, what's that preferred way? There are decimal data types in many languages and the ones that don't probably have a library for it. Anyone working with money should probably use them (especially if they could be audited).
|
# ? Feb 24, 2011 20:21 |
|
|
# ? May 16, 2024 09:22 |
|
That's not how aes_encrypt works, though. It expects to get a (random) 128-bit string. It should probably be noted in the documentation, but I don't see how this is a horror.
|
# ? Feb 24, 2011 21:19 |