Tpm2Lib.TssObject.GetPrivate C# (CSharp) Method

GetPrivate() public method

Creates a Private area for this key that will be loadable on a TPM though TPM2_Load() if the target TPM already has the parent storage key "parent" loaded. This function lets applications create key-hierarchies in software that can be loaded into a TPM once the parent has been "TPM2_Import'ed." TPM2_Import() supports plaintext import. To get this sort of import blob set intendedParent to null
public GetPrivate ( TssObject intendedParent ) : TpmPrivate
intendedParent TssObject
return TpmPrivate
        public TpmPrivate GetPrivate(TssObject intendedParent)
        {
            SymDefObject symDef = GetSymDef(intendedParent.publicPart);

            // Figure out how many bits we will need from the KDF
            byte[] parentSymValue = intendedParent.sensitivePart.seedValue;
            Transform(parentSymValue);
            byte[] iv = Globs.GetRandomBytes(SymmCipher.GetBlockSize(symDef));

            // The encryption key is calculated with a KDF
            byte[] symKey = KDF.KDFa(intendedParent.publicPart.nameAlg,
                                     parentSymValue,
                                     "STORAGE",
                                     GetName(),
                                     new byte[0],
                                     symDef.KeyBits);

            Transform(symKey);

            byte[] newPrivate = KeyWrapper.CreatePrivateFromSensitive(symDef,
                                                                      symKey,
                                                                      iv,
                                                                      sensitivePart,
                                                                      publicPart.nameAlg,
                                                                      publicPart.GetName(),
                                                                      intendedParent.publicPart.nameAlg,
                                                                      intendedParent.sensitivePart.seedValue,
                                                                      TransformerCallback);
            Transform(newPrivate);
            return new TpmPrivate(newPrivate);
        }