user322: Black's to move in a game I just played. My rival and I were wondering about castling.
Exactly:

White bishop in D6 threatens B8. Is legal for black to make long (queen) castle? (Black king and rooks have not moved)
If white bishop were in E5 threatening H8, would be legal short (king) castle?

Position:
 [title "-"]
 [fen "r3k2r/pp1nnp2/2pB2pp/3p1p2/3P4/2N3PB/PPP1PP1P/R3K2R b KQkq - 0 1"]


user11105: Yes, it is legal. The King cannot move through check, however, the King will pass through both d8 and c8, which are both legal moves. The rook has no such limitation.

user3594: Yes black is allowed to castle here. The castling would be invalidated if one of the squares along the path the king has to cross (e8 to g8 or e8 to c8) was under attack by an opponent piece. In your position, for example if the bishop was on c7, or a knight was on e6 then castling wouldn't be allowed. Whereas the bishop on d6 eyeing b8 only concerns the rook's path to complete castling, so long castling remains legal. 
Similarly, if the bishop was on e5, by the same logic short castling would still be allowed.
 [title "Position"]
 [fen "r3k2r/pp1nnp2/2pB2pp/3p1p2/3P4/2N3PB/PPP1PP1P/R3K2R b KQkq - 0 1"]

 1...O-O-O


322: <p>Black's to move in a game I just played. My rival and I were wondering about castling.</p>
<p>Exactly:</p>
<ol>
<li>White bishop in D6 threatens B8. Is legal for black to make long (queen) castle? (Black king and rooks have not moved)</li>
<li>If white bishop were in E5 threatening H8, would be legal short (king) castle?</li>
</ol>
<p>Position:</p>
<pre><code> [title &quot;-&quot;]
 [fen &quot;r3k2r/pp1nnp2/2pB2pp/3p1p2/3P4/2N3PB/PPP1PP1P/R3K2R b KQkq - 0 1&quot;]
</code></pre>
 11105: <p>Yes, it is legal. The King cannot move through check, however, the King will pass through both d8 and c8, which are both legal moves. The rook has no such limitation.</p>
 3594: <p>Yes black is allowed to castle here. The castling would be invalidated if one of the squares along the path the king has to cross (<code>e8</code> to <code>g8</code> or <code>e8</code> to <code>c8</code>) was under attack by an opponent piece. In your position, for example if the bishop was on <code>c7</code>, or a knight was on <code>e6</code> then castling wouldn't be allowed. Whereas the bishop on <code>d6</code> eyeing <code>b8</code> only concerns the rook's path to complete castling, so long castling remains legal. </p>

<p>Similarly, if the bishop was on <code>e5,</code> by the same logic short castling would still be allowed.</p>

<pre><code> [title "Position"]
 [fen "r3k2r/pp1nnp2/2pB2pp/3p1p2/3P4/2N3PB/PPP1PP1P/R3K2R b KQkq - 0 1"]

 1...O-O-O
</code></pre>
