diff --git a/src/LibHac/Tools/FsSystem/NcaUtils/Nca.cs b/src/LibHac/Tools/FsSystem/NcaUtils/Nca.cs index 0f860b4d..28e672de 100644 --- a/src/LibHac/Tools/FsSystem/NcaUtils/Nca.cs +++ b/src/LibHac/Tools/FsSystem/NcaUtils/Nca.cs @@ -65,6 +65,18 @@ public class Nca private static readonly string[] KakNames = { "application", "ocean", "system" }; + public byte[] GetEncryptedTitleKey() + { + var rightsId = new RightsId(Header.RightsId); + + if (KeySet.ExternalKeySet.Get(rightsId, out AccessKey accessKey).IsFailure()) + { + throw new MissingKeyException("Missing NCA title key.", rightsId.ToString(), KeyType.Title); + } + + return accessKey.Value.ToArray(); + } + public byte[] GetDecryptedTitleKey() { int keyRevision = Utilities.GetMasterKeyRevision(Header.KeyGeneration); diff --git a/src/hactoolnet/ProcessNca.cs b/src/hactoolnet/ProcessNca.cs index 8f2494b9..772f77ae 100644 --- a/src/hactoolnet/ProcessNca.cs +++ b/src/hactoolnet/ProcessNca.cs @@ -346,6 +346,8 @@ internal static class ProcessNca if (nca.Header.HasRightsId) { PrintItem(sb, colLen, "Rights ID:", nca.Header.RightsId.ToArray()); + PrintItem(sb, colLen, "Titlekey (Encrypted):", nca.GetEncryptedTitleKey()); + PrintItem(sb, colLen, "Titlekey (Decrypted):", nca.GetDecryptedTitleKey()); } else {