Commit Graph

24 Commits

Author SHA1 Message Date
James Wilson
23f8d829bf Change command line option processing (#82)
* Changes command line option processing:
  - Use getopt_long in libc and support long options
  - GNU style option processing (don't try to enforce non-conflicting options)
  - GNU style usage message
  - Separate encrypt and decrypt settings
  - --unprotect -> --allow-raw-read, --protect -> --no-allow-raw-read for clarification
  - Change reading key file from stdin using --key-file=-
  - Always print detailed status, remove summary "Drive Encryption" line

* Other formatting and style cleanup

* Test output changes
2022-06-01 00:05:46 +02:00
James Wilson
1200fe92ee Use hardcoded CEEM value instead of configure script parameter (#81)
The default CEEM (check external encryption mode) parameter is undocumented, and default of 0 makes behavior vendor-specific. The standard allows for a drive to report an error when trying to read a block that was pre-encrypted before written to the drive, such as is done with a keyless copy of a tape. This sounds like a very rare scenario to need to support. For the widest compatibility with data sources, this should be set to 1 for general-purpose use.
2022-05-28 11:50:08 +02:00
James Wilson
d2b7363769 clang-format run (#77)
* pull updated template .clang-format with `clang-format-14 --style=llvm --dump-config`, move to base directory so it is shared between `src` and `tests`
* tweak to match existing style a little (e.g. K&R style for function braces)
* run on all sources
2022-05-18 23:48:31 +02:00
James Wilson
86cca0804c Print algorithm information in detail output (#75)
* Print algorithm information in detail output
* Update documentation with information about algorithm listing
2022-05-18 22:28:37 +02:00
James Wilson
a7a7c4750c Do media checks on getting next block encryption status (#74)
* Do media check before getting NBES and allow getting status without media
* Supress error from BLANK CHECK sense when querying next block encryption status
2022-05-18 22:27:11 +02:00
James Wilson
8caaf85fbb Cleanup & reorganization (#73)
scsi::get_des & others should take a non-const buffer since they modify it
Reorder functions in main.cpp to declare internal functions static
Fix compile error in newer GCC (Compilation error #72) with more explicit cast
Remove some unused constants
Add KAD type enum
Pass key vector by reference instead of copying

Closes: https://github.com/scsitape/stenc/issues/72
2022-05-16 02:05:14 +02:00
James Wilson
eeb7d72686 Introduce portable, endian-clean structures using shifts and masks instead of bitfields (#66)
* Introduce portable, endian-clean structures using shifts and masks instead of bitfields
* Modernize SCSIExecute with RAII and exceptions
* Convert SP-IN calls to use the new portable SCSI structures and functions
* Convert SP-OUT code to use the new portable SCSI structures and functions
* Delete bitfield-based code and remove runtime endian check
Closes: https://github.com/scsitape/stenc/issues/63
2022-05-13 22:43:58 +02:00
James Wilson
8ebccddc50 Small cleanup: (#65)
- pass string arguments by reference
- replace macros with constexpr where possible
- move command strings out of global scope
- use standard library strerror instead of custom printer readIOError
2022-05-10 19:20:55 +02:00
James Wilson
88975cc9ed Use CAM and the pass(4) device instead of the optional sg(4) device on FreeBSD (#30) 2022-05-09 11:53:49 +02:00
James Wilson
e6ac5fa3f0 Remove AIX support (#59) 2022-05-09 01:11:07 +02:00
James Wilson
13f09ea5aa Remove KeyInfo and use standard library to parse hex strings (#46)
* Remove KeyInfo and use standard library to parse hex strings

* One declaration per line, more useful name of key_from_hex_chars
2022-05-08 21:07:58 +02:00
James Wilson
ff413aac3e Add unit tests and add const 2022-04-24 20:09:08 +02:00
Paweł Marciniak
f1a36eba42 Reintroduce HEX macro as fix
Co-authored-by: Paweł Marciniak <sunwire+git@gmail.com>
2022-04-24 16:35:52 +02:00
Jonas Stein
8ff2e4c4eb Codecleanup, Version bump 1.1.0 2022-04-22 00:47:33 +02:00
Jonas Stein
88a507932e reformat and cleanup more
reformat the source in an unified way.
(improve later with clang-format config)
fix order of includes
use proper delete[] operator
2022-04-20 00:24:59 +02:00
Jonas Stein
aa2244308d cleaned code
removed std namespace
initialized variables
cleaned endl
added const for constants
tagged new version 1.0.8
2022-04-20 00:12:52 +02:00
John Coleman
e92ccb49ff Merge pull request #17 from fpiecka/patch-1
Remove duplicate zeroing
2020-11-13 20:11:27 -07:00
Fedor Piecka
a4f407f361 Remove duplicate zeroing
memset zeroes whole &kad. No need to set it's parts to zero. Proposed in
2020-05-29 06:37:31 +02:00
Josef Meixner
e8d1f6b66b Added output of strerror to undecoded error codes 2020-04-13 12:11:26 +02:00
User Lan at serverfault.com
3cbc9a1dd5 Initialize the SCSI command properly
This fixes Sense Code:              Illegal Request (0x05)
Source:
https://serverfault.com/questions/864580/what-could-cause-a-sense-error-when-setting-lto-encryption
2018-02-14 05:03:03 +01:00
Adam Nielsen
4023deead8 Import double free bug fix from upstream git 2018-02-14 04:38:14 +01:00
Denys Berkovskyy
5e3ce59ce8 Initial port to FreeBSD 2018-02-14 04:38:05 +01:00
John Coleman
3066499e09 Import stenc-1.0.7
https://sourceforge.net/projects/stenc/files/source/stenc-1.0.7.tar.gz/download
2018-02-14 04:13:34 +01:00
John Coleman
db613c9828 Import stenc-1.0.6
Import https://sourceforge.net/projects/stenc/files/source/stenc-1.0.6.tar.gz/download
2018-02-14 04:11:24 +01:00