swupdate-enc.bbclass 874 B

12345678910111213141516171819202122232425
  1. #
  2. # The key must be generated as described in doc
  3. # with
  4. # openssl enc -aes-256-cbc -k <PASSPHRASE> -P -md sha1
  5. # The file is in the format
  6. # salt=
  7. # key=
  8. # iv=
  9. # parameters: $1 = input file, $2 = output file
  10. swu_encrypt_file() {
  11. input=$1
  12. output=$2
  13. key=`cat ${SWUPDATE_AES_FILE} | grep ^key | cut -d '=' -f 2`
  14. iv=`cat ${SWUPDATE_AES_FILE} | grep ^iv | cut -d '=' -f 2`
  15. salt=`cat ${SWUPDATE_AES_FILE} | grep ^salt | cut -d '=' -f 2`
  16. if [ -z ${salt} ] || [ -z ${key} ] || [ -z ${iv} ];then
  17. bbfatal "SWUPDATE_AES_FILE=$SWUPDATE_AES_FILE does not contain valid keys"
  18. fi
  19. openssl enc -aes-256-cbc -in ${input} -out ${output} -K ${key} -iv ${iv} -S ${salt}
  20. }
  21. CONVERSIONTYPES += "enc"
  22. CONVERSION_DEPENDS_enc = "openssl-native coreutils-native"
  23. CONVERSION_CMD_enc="swu_encrypt_file ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.enc"