Here are pertinent excerpts from articles on the Catholic Encyclopedia.
Links are given to the entire articles. You will notice that in one of them, the Council of Trent EXPLICITLY taught Baptism of Desire, and Pope St. Pius V condemned the contrary.
newadvent.org/cathen/15255a.htm
After Justina’s death Valentinian abandoned Arianism, became a catechumen, and invited St. Ambrose to come to Gaul to administer baptism to him, but was not spared to receive it. His body was brought to Milan, where the saint delivered his funeral oration, “De obitu Valentiniani consolatio”, in which he dwells on the efficacy of baptism of desire (P.L., XVI).
newadvent.org/cathen/02258b.htm#X
Substitutes for the sacrament
The Fathers and theologians frequently divide baptism into three kinds: the baptism of water (aquæ or fluminis), the baptism of desire (flaminis), and the baptism of blood (sanguinis). However, only the first is a real sacrament. The latter two are denominated baptism only analogically, inasmuch as they supply the principal effect of baptism, namely, the grace which remits sins. It is the teaching of the Catholic Church that when the baptism of water becomes a physical or moral impossibility, eternal life may be obtained by the baptism of desire or the baptism of blood.
The baptism of desire
The baptism of desire
The baptism of desire (baptismus flaminis) is a perfect contrition of heart, and every act of perfect charity or pure love of God which contains, at least implicitly, a desire (votum) of baptism. The Latin word flamen is used because Flamen is a name for the Holy Ghost, Whose special office it is to move the heart to love God and to conceive penitence for sin. The “baptism of the Holy Ghost” is a term employed in the third century by the anonymous author of the book “De Rebaptismate”. The efficacy of this baptism of desire to supply the place of the baptism of water, as to its principal effect, is proved from the words of Christ. After He had declared the necessity of baptism (John 3), He promised justifying grace for acts of charity or perfect contrition (John 14): “He that loveth Me, shall be loved of my Father: and I will love him and will manifest myself to him.” And again: “If any one love me, he will keep my word, and my Father will love him, and we will come to him, and will make our abode with him.” Since these texts declare that justifying grace is bestowed on account of acts of perfect charity or contrition, it is evident that these acts supply the place of baptism as to its principal effect, the remission of sins.
This doctrine is set forth clearly by the Council of Trent. In the fourteenth session (cap. iv) the council teaches that contrition is sometimes perfected by charity, and reconciles man to God, before the Sacrament of Penance is received.
In the fourth chapter of the sixth session, in speaking of the necessity of baptism, it says that men can not obtain original justice “except by the washing of regeneration or its desire” (voto). The same doctrine is taught by Pope Innocent III (cap. Debitum, iv, De Bapt.),** and the contrary propositions are condemned by Popes Pius V and Gregory XII, in proscribing the 31st and 33rd propositions of Baius.**
…
The baptism of blood
The baptism of blood (baptismus sanquinis) is the obtaining of the grace of justification by suffering martyrdom for the faith of Christ. The term “washing of blood” (lavacrum sanguinis) is used by Tertullian (On Baptism 16) to distinguish this species of regeneration from the “washing of water” (lavacrum aquæ). “We have a second washing”, he says “which is one and the same [with the first], namely the washing of blood.” St. Cyprian (Epistle 73) speaks of “the most glorious and greatest baptism of blood” (sanguinis baptismus). St. Augustine (City of God 13.7) says: “When any die for the confession of Christ without having received the washing of regeneration, it avails as much for the remission of their sins as if they had been washed in the sacred font of baptism.”
…