Skip to content
Snippets Groups Projects
  • Jungmin Park's avatar
    bf98afc7
    crypto/luks: Support creating LUKS image on Darwin · bf98afc7
    Jungmin Park authored
    
    When the user creates a LUKS-encrypted qcow2 image using the qemu-img
    program, the passphrase is hashed using PBKDF2 with a dynamic
    number of iterations. The number of iterations is determined by
    measuring thread cpu time usage, such that it takes approximately
    2 seconds to compute the hash.
    
    Because Darwin doesn't implement getrusage(RUSAGE_THREAD), we get an
    error message:
    > qemu-img: test.qcow2: Unable to calculate thread CPU usage on this platform
    for this command:
    > qemu-img create --object secret,id=key,data=1234 -f qcow2 -o 'encrypt.format=luks,encrypt.key-secret=key' test.qcow2 100M
    
    This patch implements qcrypto_pbkdf2_get_thread_cpu() for Darwin so that
    the above command works.
    
    Signed-off-by: default avatarJungmin Park <pjm0616@gmail.com>
    Signed-off-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
    bf98afc7
    History
    crypto/luks: Support creating LUKS image on Darwin
    Jungmin Park authored
    
    When the user creates a LUKS-encrypted qcow2 image using the qemu-img
    program, the passphrase is hashed using PBKDF2 with a dynamic
    number of iterations. The number of iterations is determined by
    measuring thread cpu time usage, such that it takes approximately
    2 seconds to compute the hash.
    
    Because Darwin doesn't implement getrusage(RUSAGE_THREAD), we get an
    error message:
    > qemu-img: test.qcow2: Unable to calculate thread CPU usage on this platform
    for this command:
    > qemu-img create --object secret,id=key,data=1234 -f qcow2 -o 'encrypt.format=luks,encrypt.key-secret=key' test.qcow2 100M
    
    This patch implements qcrypto_pbkdf2_get_thread_cpu() for Darwin so that
    the above command works.
    
    Signed-off-by: default avatarJungmin Park <pjm0616@gmail.com>
    Signed-off-by: default avatarDaniel P. Berrangé <berrange@redhat.com>