Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to use the encrypt/decrypt command on solaris

 /usr/bin/encrypt -l | -a algorithm [-v]  [-k  key_file]  [-i
 input_file] [-o output_file]

 /usr/bin/decrypt -l | -a algorithm [-v]  [-k  key_file]  [-i
 input_file] [-o output_file]

but i am prompted for a key. so i use the -k option and specify the key in a file. But in that case it gives me an error. any idea where i am going wrong?

 $ encrypt -a aes -k key.txt -i res.txt -o out.txt
 **encrypt: failed to generate a key: CKR_ATTRIBUTE_VALUE_INVALID**

File contents:

 $ cat res.txt
 8787878787878787
 $ cat key.txt
 111000110010100100100011001011101010011011010000110101110011000
share|improve this question

migrated from stackoverflow.com May 29 '13 at 9:42

This question came from our site for professional and enthusiast programmers.

    
This may help you : docs.oracle.com/cd/E19082-01/819-3321/scftask-4/index.html –  fedorqui May 29 '13 at 4:12
    
Thank you fedorqui, but i referred to that document before trying that out. I am afraid it hasnt helped me much in terms of "waht the key should be" it only says towards the end that the message CKR_ATTRIBUTE_VALUE_INVALID indicates an invalid key, which is why i am here seeking assistance. –  user2404176 May 29 '13 at 4:32
    
Yes, the error message sums it up -- this key is invalid. Check the key length. Your best bet is to regenerate the key. –  devnull May 29 '13 at 6:11
1  
Thanks. Maybe I am missing something here. When you say "generate" I have no clue, I opened a file and typed that in. Is there a way to generate the AES key ? I have never gone into Cryptography before so maybe i should read about key lengths. But any information is appreciated. –  user2404176 May 29 '13 at 6:21
add comment

1 Answer

up vote 2 down vote accepted

The key is, indeed, invalid as reported in the error message.

You need to regenerate the key. You can generate the key using dd or pktool. An example would be:

dd if=/dev/urandom of=/path/to/aes.key bs=16 count=1

Refer to How to Generate a Symmetric Key by Using the dd Command and How to Generate a Symmetric Key by Using the pktool Command for more.

share|improve this answer
    
awesome! it worked!! no errors! thank you Devnull! –  user2404176 May 29 '13 at 8:24
    
just curious to understand what that syntax means, while i read about it, i was trying to set the if to something else than /dev/urandom. I have text "blake" in a file. can i use that?? –  user2404176 May 29 '13 at 9:03
    
If you could use I have text "blake" in a file, chances are that you wouldn't have run into this problem with your original key. –  devnull May 29 '13 at 9:05
    
so i can only use urandom if i understand you correctly. right? –  user2404176 May 29 '13 at 9:09
    
urandom isn't a command, it's a device (man urandom). You can use either dd or pktool as mentioned above. –  devnull May 29 '13 at 9:12
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.