/// <summary> /// For use only when decrypting a volume member. /// <para>Resets the Expired flag; useage must guarantee that the same key-to-file matching is used when re-encrypting the file.</para> /// </summary> /// /// <param name="KeyId">The unique subkey id</param> public void ResetSubKeyFlag(byte[] KeyId) { if (AccessScope.Equals(KeyScope.NoAccess)) { throw new CryptoProcessingException("PackageFactory:Extract", "You do not have permission to access this key!", new UnauthorizedAccessException()); } try { long keyPos; int index; // get the key data MemoryStream keyStream = GetKeyStream(); // get the keying materials starting offset within the key file keyPos = PackageKey.SubKeyOffset(keyStream, KeyId); if (keyPos == -1) { throw new CryptoProcessingException("PackageFactory:Extract", "This package does not contain the key file!", new ArgumentException()); } // get the index index = PackageKey.IndexFromId(keyStream, KeyId); PackageKey.SubKeyClearPolicy(keyStream, index, (long)PackageKeyStates.Expired); // write to file WriteKeyStream(keyStream); } catch { throw; } }
/// <summary> /// For use only when decrypting a volume member. /// <para>Resets the Expired flag; useage must guarantee that the same key-to-file matching is used when re-encrypting the file.</para> /// </summary> /// /// <param name="Index">The subkey index</param> public void ResetSubKeyFlag(int Index) { if (AccessScope.Equals(KeyScope.NoAccess)) { throw new CryptoProcessingException("PackageFactory:Extract", "You do not have permission to access this key!", new UnauthorizedAccessException()); } try { // get the key data MemoryStream keyStream = GetKeyStream(); PackageKey.SubKeyClearPolicy(keyStream, Index, (long)PackageKeyStates.Expired); // write to file WriteKeyStream(keyStream); } catch { throw; } }