From 011f7069677c77ee3039d94aef7bc25030ab3309 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Thu, 31 Oct 2019 21:30:06 -0500 Subject: hscript: Implement Encrypt, add tests --- hscript/disk.cc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'hscript/disk.cc') diff --git a/hscript/disk.cc b/hscript/disk.cc index 05fb6d2..ad253b3 100644 --- a/hscript/disk.cc +++ b/hscript/disk.cc @@ -233,6 +233,37 @@ bool DiskLabel::execute(ScriptOptions options) const { } +Key *Encrypt::parseFromData(const std::string &data, int lineno, int *errors, + int *) { + std::string::size_type sep = data.find(' '); + std::string dev, pass; + + if(sep == std::string::npos) { + dev = data; + } else { + dev = data.substr(0, sep); + pass = data.substr(sep + 1); + } + + if(dev.size() < 6 || dev.compare(0, 5, "/dev/")) { + if(errors) *errors += 1; + output_error("installfile:" + std::to_string(lineno), + "encrypt: expected path to block device"); + return nullptr; + } + + return new Encrypt(lineno, dev, pass); +} + +bool Encrypt::validate(ScriptOptions) const { + return true; +} + +bool Encrypt::execute(ScriptOptions) const { + return false; +} + + /*! Parse a size string into a size and type. * @param in_size (in) The string to parse. * @param out_size (out) Where to which to write the size in bytes or %. -- cgit v1.2.3-60-g2f50