|
| 1 | +-- |
| 2 | +-- Blowfish cipher |
| 3 | +-- |
| 4 | +-- ensure consistent test output regardless of the default bytea format |
| 5 | +SET bytea_output TO escape; |
| 6 | +-- some standard Blowfish testvalues |
| 7 | +SELECT encode(encrypt( |
| 8 | +decode('0000000000000000', 'hex'), |
| 9 | +decode('0000000000000000', 'hex'), |
| 10 | +'bf-ecb/pad:none'), 'hex'); |
| 11 | +ERROR: encrypt error: Cipher cannot be initialized ? |
| 12 | +SELECT encode(encrypt( |
| 13 | +decode('ffffffffffffffff', 'hex'), |
| 14 | +decode('ffffffffffffffff', 'hex'), |
| 15 | +'bf-ecb/pad:none'), 'hex'); |
| 16 | +ERROR: encrypt error: Cipher cannot be initialized ? |
| 17 | +SELECT encode(encrypt( |
| 18 | +decode('1000000000000001', 'hex'), |
| 19 | +decode('3000000000000000', 'hex'), |
| 20 | +'bf-ecb/pad:none'), 'hex'); |
| 21 | +ERROR: encrypt error: Cipher cannot be initialized ? |
| 22 | +SELECT encode(encrypt( |
| 23 | +decode('1111111111111111', 'hex'), |
| 24 | +decode('1111111111111111', 'hex'), |
| 25 | +'bf-ecb/pad:none'), 'hex'); |
| 26 | +ERROR: encrypt error: Cipher cannot be initialized ? |
| 27 | +SELECT encode(encrypt( |
| 28 | +decode('0123456789abcdef', 'hex'), |
| 29 | +decode('fedcba9876543210', 'hex'), |
| 30 | +'bf-ecb/pad:none'), 'hex'); |
| 31 | +ERROR: encrypt error: Cipher cannot be initialized ? |
| 32 | +SELECT encode(encrypt( |
| 33 | +decode('01a1d6d039776742', 'hex'), |
| 34 | +decode('fedcba9876543210', 'hex'), |
| 35 | +'bf-ecb/pad:none'), 'hex'); |
| 36 | +ERROR: encrypt error: Cipher cannot be initialized ? |
| 37 | +SELECT encode(encrypt( |
| 38 | +decode('ffffffffffffffff', 'hex'), |
| 39 | +decode('0000000000000000', 'hex'), |
| 40 | +'bf-ecb/pad:none'), 'hex'); |
| 41 | +ERROR: encrypt error: Cipher cannot be initialized ? |
| 42 | +-- setkey |
| 43 | +SELECT encode(encrypt( |
| 44 | +decode('fedcba9876543210', 'hex'), |
| 45 | +decode('f0e1d2c3b4a5968778695a4b3c2d1e0f', 'hex'), |
| 46 | +'bf-ecb/pad:none'), 'hex'); |
| 47 | +ERROR: encrypt error: Cipher cannot be initialized ? |
| 48 | +-- with padding |
| 49 | +SELECT encode(encrypt( |
| 50 | +decode('01234567890123456789', 'hex'), |
| 51 | +decode('33443344334433443344334433443344', 'hex'), |
| 52 | +'bf-ecb'), 'hex'); |
| 53 | +ERROR: encrypt error: Cipher cannot be initialized ? |
| 54 | +-- cbc |
| 55 | +-- 28 bytes key |
| 56 | +SELECT encode(encrypt( |
| 57 | +decode('6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5', 'hex'), |
| 58 | +decode('37363534333231204e6f77206973207468652074696d6520666f7220', 'hex'), |
| 59 | +'bf-cbc'), 'hex'); |
| 60 | +ERROR: encrypt error: Key was too big |
| 61 | +-- 29 bytes key |
| 62 | +SELECT encode(encrypt( |
| 63 | +decode('6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5ff92cc', 'hex'), |
| 64 | +decode('37363534333231204e6f77206973207468652074696d6520666f722000', 'hex'), |
| 65 | +'bf-cbc'), 'hex'); |
| 66 | +ERROR: encrypt error: Key was too big |
| 67 | +-- blowfish-448 |
| 68 | +SELECT encode(encrypt( |
| 69 | +decode('fedcba9876543210', 'hex'), |
| 70 | +decode('f0e1d2c3b4a5968778695a4b3c2d1e0f001122334455667704689104c2fd3b2f584023641aba61761f1f1f1f0e0e0e0effffffffffffffff', 'hex'), |
| 71 | +'bf-ecb/pad:none'), 'hex'); |
| 72 | +ERROR: encrypt error: Key was too big |
| 73 | +-- result: c04504012e4e1f53 |
| 74 | +-- empty data |
| 75 | +select encode(encrypt('', 'foo', 'bf'), 'hex'); |
| 76 | +ERROR: encrypt error: Cipher cannot be initialized ? |
| 77 | +-- 10 bytes key |
| 78 | +select encode(encrypt('foo', '0123456789', 'bf'), 'hex'); |
| 79 | +ERROR: encrypt error: Cipher cannot be initialized ? |
| 80 | +-- 22 bytes key |
| 81 | +select encode(encrypt('foo', '0123456789012345678901', 'bf'), 'hex'); |
| 82 | +ERROR: encrypt error: Key was too big |
| 83 | +-- decrypt |
| 84 | +select decrypt(encrypt('foo', '0123456', 'bf'), '0123456', 'bf'); |
| 85 | +ERROR: encrypt error: Cipher cannot be initialized ? |
| 86 | +-- iv |
| 87 | +select encode(encrypt_iv('foo', '0123456', 'abcd', 'bf'), 'hex'); |
| 88 | +ERROR: encrypt_iv error: Cipher cannot be initialized ? |
| 89 | +select decrypt_iv(decode('95c7e89322525d59', 'hex'), '0123456', 'abcd', 'bf'); |
| 90 | +ERROR: decrypt_iv error: Cipher cannot be initialized ? |
| 91 | +-- long message |
| 92 | +select encode(encrypt('Lets try a longer message.', '0123456789', 'bf'), 'hex'); |
| 93 | +ERROR: encrypt error: Cipher cannot be initialized ? |
| 94 | +select decrypt(encrypt('Lets try a longer message.', '0123456789', 'bf'), '0123456789', 'bf'); |
| 95 | +ERROR: encrypt error: Cipher cannot be initialized ? |
0 commit comments