Package net.i2p.crypto
Class SU3File
java.lang.Object
net.i2p.crypto.SU3File
public class SU3File extends Object
Succesor to the ".sud" format used in TrustedUpdate.
Format specified in http://www.i2p2.de/updates
- Since:
- 0.9.8
-
Field Summary
Fields Modifier and Type Field Description static intCONTENT_BLOCKLISTstatic intCONTENT_NEWSstatic intCONTENT_PLUGINstatic intCONTENT_RESEEDstatic intCONTENT_ROUTERstatic intCONTENT_UNKNOWNstatic StringMAGICstatic intTYPE_DMGstatic intTYPE_EXEstatic intTYPE_HTMLstatic intTYPE_TXT_GZstatic intTYPE_XMLstatic intTYPE_XML_GZstatic intTYPE_ZIPThe file type is advisory and is application-dependent. -
Constructor Summary
-
Method Summary
Modifier and Type Method Description intgetContentType()The ContentType is the trust domain for the content.intgetFileType()The file type is advisory and is application-dependent.StringgetSignerString()This does not check the signature, but it will fail if the signer is unknown, unless setVerifySignature(false) has been called.SigTypegetSigType()This does not check the signature, but it will fail if the signer is unknown, unless setVerifySignature(false) has been called.StringgetVersionString()This does not check the signature, but it will fail if the signer is unknown, unless setVerifySignature(false) has been called.static voidmain(String[] args)Parses command line arguments when this class is used from the command line.voidsetVerifySignature(boolean shouldVerify)Should the signature be verified? Default truebooleanverify()One-pass verify.booleanverifyAndMigrate(File migrateTo)One-pass verify and extract the content.voidverifyHeader()This does not check the signature, but it will fail if the signer is unknown, unless setVerifySignature(false) has been called.voidwrite(File content, int fileType, int contentType, String version, String signer, PrivateKey privkey, SigType sigType)One-pass wrap and sign the content.
-
Field Details
-
MAGIC
- See Also:
- Constant Field Values
-
TYPE_ZIP
public static final int TYPE_ZIPThe file type is advisory and is application-dependent. The following values are defined but any value 0-255 is allowed.- See Also:
- Constant Field Values
-
TYPE_XML
public static final int TYPE_XML- Since:
- 0.9.15
- See Also:
- Constant Field Values
-
TYPE_HTML
public static final int TYPE_HTML- Since:
- 0.9.15
- See Also:
- Constant Field Values
-
TYPE_XML_GZ
public static final int TYPE_XML_GZ- Since:
- 0.9.17
- See Also:
- Constant Field Values
-
TYPE_TXT_GZ
public static final int TYPE_TXT_GZ- Since:
- 0.9.28
- See Also:
- Constant Field Values
-
TYPE_DMG
public static final int TYPE_DMG- Since:
- 0.9.51
- See Also:
- Constant Field Values
-
TYPE_EXE
public static final int TYPE_EXE- Since:
- 0.9.51
- See Also:
- Constant Field Values
-
CONTENT_UNKNOWN
public static final int CONTENT_UNKNOWN- See Also:
- Constant Field Values
-
CONTENT_ROUTER
public static final int CONTENT_ROUTER- See Also:
- Constant Field Values
-
CONTENT_PLUGIN
public static final int CONTENT_PLUGIN- See Also:
- Constant Field Values
-
CONTENT_RESEED
public static final int CONTENT_RESEED- See Also:
- Constant Field Values
-
CONTENT_NEWS
public static final int CONTENT_NEWS- Since:
- 0.9.15
- See Also:
- Constant Field Values
-
CONTENT_BLOCKLIST
public static final int CONTENT_BLOCKLIST- Since:
- 0.9.28
- See Also:
- Constant Field Values
-
-
Constructor Details
-
Method Details
-
setVerifySignature
public void setVerifySignature(boolean shouldVerify)Should the signature be verified? Default true- Since:
- 0.9.15
-
getVersionString
This does not check the signature, but it will fail if the signer is unknown, unless setVerifySignature(false) has been called.- Throws:
IOException
-
getSignerString
This does not check the signature, but it will fail if the signer is unknown, unless setVerifySignature(false) has been called.- Throws:
IOException
-
getSigType
This does not check the signature, but it will fail if the signer is unknown, unless setVerifySignature(false) has been called.- Returns:
- null if unknown
- Throws:
IOException- Since:
- 0.9.9
-
getContentType
The ContentType is the trust domain for the content. The signer and signature will be checked with the trusted certificates for that type. This does not check the signature, but it will fail if the signer is unknown, unless setVerifySignature(false) has been called.- Returns:
- -1 if unknown
- Throws:
IOException- Since:
- 0.9.9
-
getFileType
The file type is advisory and is application-dependent. The following values are defined but any value 0-255 is allowed. This does not check the signature, but it will fail if the signer is unknown, unless setVerifySignature(false) has been called.- Returns:
- 0-255 or -1 if unknown
- Throws:
IOException- Since:
- 0.9.15
-
verifyHeader
This does not check the signature, but it will fail if the signer is unknown, unless setVerifySignature(false) has been called. Throws IOE if verify vails.- Throws:
IOException
-
verify
One-pass verify. Throws IOE on all format errors.- Returns:
- true if signature is good
- Throws:
IOException- Since:
- 0.9.9
-
verifyAndMigrate
One-pass verify and extract the content. Recommend extracting to a temp location as the sig is not checked until after extraction. This will delete the file if the sig does not verify. Throws IOE on all format errors.- Parameters:
migrateTo- the output file, probably in zip format. Null for verify only.- Returns:
- true if signature is good
- Throws:
IOException
-
write
public void write(File content, int fileType, int contentType, String version, String signer, PrivateKey privkey, SigType sigType) throws IOExceptionOne-pass wrap and sign the content. Writes to the file specified in the constructor. Throws on all errors.- Parameters:
content- the input file, probably in zip formatfileType- 0-255, 0 for zipcontentType- 0-255version- 1-255 bytes when converted to UTF-8signer- ID of the public key, 1-255 bytes when converted to UTF-8- Throws:
IOException
-
main
Parses command line arguments when this class is used from the command line. Exits 1 on failure so this can be used in scripts.- Parameters:
args- Command line parameters.
-