protected void createEncryptionInfoEntry(DirectoryNode dir, File tmpFile) throws IOException, GeneralSecurityException { DataSpaceMapUtils.addDefaultDataSpace(dir); final EncryptionInfo info = getEncryptionInfo(); EncryptionRecord er = new EncryptionRecord(){ @Override public void write(LittleEndianByteArrayOutputStream bos) { // EncryptionVersionInfo (4 bytes): A Version structure (section 2.1.4), where // Version.vMajor MUST be 0x0004 and Version.vMinor MUST be 0x0004 bos.writeShort(info.getVersionMajor()); bos.writeShort(info.getVersionMinor()); // Reserved (4 bytes): A value that MUST be 0x00000040 bos.writeInt(info.getEncryptionFlags()); EncryptionDocument ed = createEncryptionDocument(); marshallEncryptionDocument(ed, bos); } }; createEncryptionEntry(dir, "EncryptionInfo", er); }
public DataSpaceMapEntry(LittleEndianInput is) { /*int length = */ is.readInt(); int referenceComponentCount = is.readInt(); referenceComponentType = new int[referenceComponentCount]; referenceComponent = new String[referenceComponentCount]; for (int i=0; i<referenceComponentCount; i++) { referenceComponentType[i] = is.readInt(); referenceComponent[i] = readUnicodeLPP4(is); } dataSpaceName = readUnicodeLPP4(is); }
public IRMDSTransformInfo(LittleEndianInput is) { transformInfoHeader = new TransformInfoHeader(is); extensibilityHeader = is.readInt(); xrMLLicense = readUtf8LPP4(is); // finish with 0x04 (int) ??? }
public static void addDefaultDataSpace(DirectoryEntry dir) throws IOException { DataSpaceMapEntry dsme = new DataSpaceMapEntry( new int[]{ 0 } , new String[]{ Decryptor.DEFAULT_POIFS_ENTRY } , "StrongEncryptionDataSpace" ); DataSpaceMap dsm = new DataSpaceMap(new DataSpaceMapEntry[]{dsme}); createEncryptionEntry(dir, "\u0006DataSpaces/DataSpaceMap", dsm); DataSpaceDefinition dsd = new DataSpaceDefinition(new String[]{ "StrongEncryptionTransform" }); createEncryptionEntry(dir, "\u0006DataSpaces/DataSpaceInfo/StrongEncryptionDataSpace", dsd); TransformInfoHeader tih = new TransformInfoHeader( 1 , "{FF9A3F03-56EF-4613-BDD5-5A41C1D07246}" , "Microsoft.Container.EncryptionTransform" , 1, 0, 1, 0, 1, 0 ); IRMDSTransformInfo irm = new IRMDSTransformInfo(tih, 0, null); createEncryptionEntry(dir, "\u0006DataSpaces/TransformInfo/StrongEncryptionTransform/\u0006Primary", irm); DataSpaceVersionInfo dsvi = new DataSpaceVersionInfo("Microsoft.Container.DataSpaces", 1, 0, 1, 0, 1, 0); createEncryptionEntry(dir, "\u0006DataSpaces/Version", dsvi); }
public void write(LittleEndianByteArrayOutputStream bos) { bos.writeInt(8); bos.writeInt(transformer.length); for (String str : transformer) { writeUnicodeLPP4(bos, str); } } }
@Override public OutputStream getDataStream(final DirectoryNode dir) throws IOException, GeneralSecurityException { createEncryptionInfoEntry(dir); DataSpaceMapUtils.addDefaultDataSpace(dir); return new StandardCipherOutputStream(dir); }
public void write(LittleEndianByteArrayOutputStream bos) { transformInfoHeader.write(bos); bos.writeInt(extensibilityHeader); writeUtf8LPP4(bos, xrMLLicense); bos.writeInt(4); // where does this 4 come from??? } }
protected void createEncryptionInfoEntry(DirectoryNode dir) throws IOException { final EncryptionInfo info = getEncryptionInfo(); final StandardEncryptionHeader header = (StandardEncryptionHeader)info.getHeader(); final StandardEncryptionVerifier verifier = (StandardEncryptionVerifier)info.getVerifier(); EncryptionRecord er = new EncryptionRecord(){ @Override public void write(LittleEndianByteArrayOutputStream bos) { bos.writeShort(info.getVersionMajor()); bos.writeShort(info.getVersionMinor()); bos.writeInt(info.getEncryptionFlags()); header.write(bos); verifier.write(bos); } }; createEncryptionEntry(dir, "EncryptionInfo", er); // TODO: any properties??? }
public void write(LittleEndianByteArrayOutputStream os) { int start = os.getWriteIndex(); LittleEndianOutput sizeOut = os.createDelayedOutput(LittleEndianConsts.INT_SIZE); os.writeInt(referenceComponent.length); for (int i=0; i<referenceComponent.length; i++) { os.writeInt(referenceComponentType[i]); writeUnicodeLPP4(os, referenceComponent[i]); } writeUnicodeLPP4(os, dataSpaceName); sizeOut.writeInt(os.getWriteIndex()-start); } }
@Override public OutputStream getDataStream(final DirectoryNode dir) throws IOException, GeneralSecurityException { createEncryptionInfoEntry(dir); DataSpaceMapUtils.addDefaultDataSpace(dir); return new StandardCipherOutputStream(dir); }
public void write(LittleEndianByteArrayOutputStream bos) { transformInfoHeader.write(bos); bos.writeInt(extensibilityHeader); writeUtf8LPP4(bos, xrMLLicense); bos.writeInt(4); // where does this 4 come from??? } }
protected void createEncryptionInfoEntry(DirectoryNode dir) throws IOException { DataSpaceMapUtils.addDefaultDataSpace(dir); final EncryptionInfo info = getEncryptionInfo(); final BinaryRC4EncryptionHeader header = (BinaryRC4EncryptionHeader)info.getHeader(); final BinaryRC4EncryptionVerifier verifier = (BinaryRC4EncryptionVerifier)info.getVerifier(); EncryptionRecord er = new EncryptionRecord() { @Override public void write(LittleEndianByteArrayOutputStream bos) { bos.writeShort(info.getVersionMajor()); bos.writeShort(info.getVersionMinor()); header.write(bos); verifier.write(bos); } }; DataSpaceMapUtils.createEncryptionEntry(dir, "EncryptionInfo", er); }
public static void addDefaultDataSpace(DirectoryEntry dir) throws IOException { DataSpaceMapEntry dsme = new DataSpaceMapEntry( new int[]{ 0 } , new String[]{ Decryptor.DEFAULT_POIFS_ENTRY } , "StrongEncryptionDataSpace" ); DataSpaceMap dsm = new DataSpaceMap(new DataSpaceMapEntry[]{dsme}); createEncryptionEntry(dir, "\u0006DataSpaces/DataSpaceMap", dsm); DataSpaceDefinition dsd = new DataSpaceDefinition(new String[]{ "StrongEncryptionTransform" }); createEncryptionEntry(dir, "\u0006DataSpaces/DataSpaceInfo/StrongEncryptionDataSpace", dsd); TransformInfoHeader tih = new TransformInfoHeader( 1 , "{FF9A3F03-56EF-4613-BDD5-5A41C1D07246}" , "Microsoft.Container.EncryptionTransform" , 1, 0, 1, 0, 1, 0 ); IRMDSTransformInfo irm = new IRMDSTransformInfo(tih, 0, null); createEncryptionEntry(dir, "\u0006DataSpaces/TransformInfo/StrongEncryptionTransform/\u0006Primary", irm); DataSpaceVersionInfo dsvi = new DataSpaceVersionInfo("Microsoft.Container.DataSpaces", 1, 0, 1, 0, 1, 0); createEncryptionEntry(dir, "\u0006DataSpaces/Version", dsvi); }
public DataSpaceDefinition(LittleEndianInput is) { /* int headerLength = */ is.readInt(); int transformReferenceCount = is.readInt(); transformer = new String[transformReferenceCount]; for (int i=0; i<transformReferenceCount; i++) { transformer[i] = readUnicodeLPP4(is); } }
public void write(LittleEndianByteArrayOutputStream bos) { writeUnicodeLPP4(bos, featureIdentifier); bos.writeShort(readerVersionMajor); bos.writeShort(readerVersionMinor); bos.writeShort(updaterVersionMajor); bos.writeShort(updaterVersionMinor); bos.writeShort(writerVersionMajor); bos.writeShort(writerVersionMinor); } }
public IRMDSTransformInfo(LittleEndianInput is) { transformInfoHeader = new TransformInfoHeader(is); extensibilityHeader = is.readInt(); xrMLLicense = readUtf8LPP4(is); // finish with 0x04 (int) ??? }
protected void createEncryptionInfoEntry(DirectoryNode dir, File tmpFile) throws IOException, GeneralSecurityException { DataSpaceMapUtils.addDefaultDataSpace(dir); final EncryptionInfo info = getEncryptionInfo(); EncryptionRecord er = new EncryptionRecord(){ @Override public void write(LittleEndianByteArrayOutputStream bos) { // EncryptionVersionInfo (4 bytes): A Version structure (section 2.1.4), where // Version.vMajor MUST be 0x0004 and Version.vMinor MUST be 0x0004 bos.writeShort(info.getVersionMajor()); bos.writeShort(info.getVersionMinor()); // Reserved (4 bytes): A value that MUST be 0x00000040 bos.writeInt(info.getEncryptionFlags()); EncryptionDocument ed = createEncryptionDocument(); marshallEncryptionDocument(ed, bos); } }; createEncryptionEntry(dir, "EncryptionInfo", er); }
protected void createEncryptionInfoEntry(DirectoryNode dir) throws IOException { final EncryptionInfo info = getEncryptionInfo(); final StandardEncryptionHeader header = (StandardEncryptionHeader)info.getHeader(); final StandardEncryptionVerifier verifier = (StandardEncryptionVerifier)info.getVerifier(); EncryptionRecord er = new EncryptionRecord(){ @Override public void write(LittleEndianByteArrayOutputStream bos) { bos.writeShort(info.getVersionMajor()); bos.writeShort(info.getVersionMinor()); bos.writeInt(info.getEncryptionFlags()); header.write(bos); verifier.write(bos); } }; createEncryptionEntry(dir, "EncryptionInfo", er); // TODO: any properties??? }
public TransformInfoHeader(LittleEndianInput is) { /* int length = */ is.readInt(); transformType = is.readInt(); transformerId = readUnicodeLPP4(is); transformerName = readUnicodeLPP4(is); readerVersionMajor = is.readShort(); readerVersionMinor = is.readShort(); updaterVersionMajor = is.readShort(); updaterVersionMinor = is.readShort(); writerVersionMajor = is.readShort(); writerVersionMinor = is.readShort(); }
public void write(LittleEndianByteArrayOutputStream bos) { int start = bos.getWriteIndex(); LittleEndianOutput sizeOut = bos.createDelayedOutput(LittleEndianConsts.INT_SIZE); bos.writeInt(transformType); writeUnicodeLPP4(bos, transformerId); sizeOut.writeInt(bos.getWriteIndex()-start); writeUnicodeLPP4(bos, transformerName); bos.writeShort(readerVersionMajor); bos.writeShort(readerVersionMinor); bos.writeShort(updaterVersionMajor); bos.writeShort(updaterVersionMinor); bos.writeShort(writerVersionMajor); bos.writeShort(writerVersionMinor); } }