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 Details

  • Constructor Details

    • SU3File

      public SU3File(String file)
    • SU3File

      public SU3File(File file)
    • SU3File

      public SU3File(I2PAppContext context, File file)
  • Method Details

    • setVerifySignature

      public void setVerifySignature(boolean shouldVerify)
      Should the signature be verified? Default true
      Since:
      0.9.15
    • getVersionString

      public String getVersionString() throws IOException
      This does not check the signature, but it will fail if the signer is unknown, unless setVerifySignature(false) has been called.
      Throws:
      IOException
    • getSignerString

      public String getSignerString() throws IOException
      This does not check the signature, but it will fail if the signer is unknown, unless setVerifySignature(false) has been called.
      Throws:
      IOException
    • getSigType

      public SigType getSigType() throws IOException
      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

      public int getContentType() throws IOException
      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

      public int getFileType() throws IOException
      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

      public void verifyHeader() throws IOException
      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

      public boolean verify() throws IOException
      One-pass verify. Throws IOE on all format errors.
      Returns:
      true if signature is good
      Throws:
      IOException
      Since:
      0.9.9
    • verifyAndMigrate

      public boolean verifyAndMigrate(File migrateTo) throws IOException
      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 IOException
      One-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 format
      fileType - 0-255, 0 for zip
      contentType - 0-255
      version - 1-255 bytes when converted to UTF-8
      signer - ID of the public key, 1-255 bytes when converted to UTF-8
      Throws:
      IOException
    • main

      public static void main(String[] args)
      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.